How to use the channels.asgi.get_channel_layer function in channels

To help you get started, we’ve selected a few channels examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github 007gzs / django_restframework_apiview / example / example / asgi.py View on Github external
# encoding: utf-8
from __future__ import absolute_import, unicode_literals

import os
import channels.asgi

os.environ.setdefault("DJANGO_SETTINGS_MODULE", "example.settings")
channel_layer = channels.asgi.get_channel_layer()
github pixelpassion / drf-saas-starter / main / asgi.py View on Github external
import os

from channels.asgi import get_channel_layer

os.environ.setdefault("DJANGO_SETTINGS_MODULE", "main.settings")

channel_layer = get_channel_layer()
github andrewgodwin / channels-examples / liveblog / liveblog / asgi.py View on Github external
"""
ASGI entrypoint file for default channel layer.

Points to the channel layer configured as "default" so you can point
ASGI applications at "liveblog.asgi:channel_layer" as their channel layer.
"""

import os
from channels.asgi import get_channel_layer
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "liveblog.settings.redis")
channel_layer = get_channel_layer()
github phildini / logtacts / logtacts / wsgi.py View on Github external
"""
WSGI config for logtacts project.

It exposes the WSGI callable as a module-level variable named ``application``.

For more information on this file, see
https://docs.djangoproject.com/en/1.7/howto/deployment/wsgi/
"""
import os
from asgiref.wsgi import WsgiToAsgiAdapter
from channels.asgi import get_channel_layer

os.environ.setdefault("DJANGO_SETTINGS_MODULE", "logtacts.prod_settings")
channel_layer = get_channel_layer()
application = WsgiToAsgiAdapter(channel_layer)
github ilavender / sensu_drive / isubscribe / views.py View on Github external
#data = channel_layer.group_channels('notifications')
    #data = channel_layer.global_statistics()
    #data = channel_layer.channel_statistics('notifications')
    #data = get_channel_layer().group_channels('notifications')    
    #data = Group("notifications").extensions
    #data = get_channel_layer().receive_twisted()
    
    #from channels import channel_layers
    #layer = channel_layers["default"]
    #print(layer.router.channels)    
    
    data = []
    
    
    from django.contrib.sessions.backends import cache as engine
    data = get_channel_layer().group_channels('notifications')
    
    active_users = []
    for C in data:        
        #Channel(C).send({"text": json.dumps({'clean_signal':True})})
        c_session = session_for_reply_channel(C)        
        session = engine.SessionStore(c_session._session_key)        
        
        #print(c_session._session['_auth_user_id'])
        #print(session.keys())
        #print(session.get('username', None), session.get_expiry_date())
        
        username = session.get('username', None)
        # this is the same
        # username = c_session.get('username', None)
        if username not in active_users and username != None:
            active_users.append(username)
github Murali-group / GraphSpace / graphspace / asgi.py View on Github external
import os
from channels.asgi import get_channel_layer

os.environ.setdefault("DJANGO_SETTINGS_MODULE", "graphspace.settings.production")

channel_layer = get_channel_layer()

from graphspace.database import *
from django.conf import settings
settings.db = Database()

from applications.notifications.consumer import *

# Start owner notification consumer
ocon = Consumer("owner")
ocon.start()

# Start group notification consumer
gcon = Consumer("group")
gcon.start()
github ansible / awx / awx / asgi.py View on Github external
if MODE == 'production':
    logger = logging.getLogger('awx.main.models.jobs')
    try:
        fd = open("/var/lib/awx/.tower_version", "r")
        if fd.read().strip() != tower_version:
            raise Exception()
    except Exception:
        logger.error("Missing or incorrect metadata for Tower version.  Ensure Tower was installed using the setup playbook.")
        raise Exception("Missing or incorrect metadata for Tower version.  Ensure Tower was installed using the setup playbook.")


os.environ.setdefault("DJANGO_SETTINGS_MODULE", "awx.settings")


channel_layer = get_channel_layer()
github teritos / tero-saas / settings / asgi.py View on Github external
import os
from channels.asgi import get_channel_layer


os.environ.setdefault("DJANGO_SETTINGS_MODULE", "settings.dev_settings")


channel_layer = get_channel_layer()
github KDD-OpenSource / fexum / fexum / asgi.py View on Github external
import os
from channels.asgi import get_channel_layer

os.environ.setdefault("DJANGO_SETTINGS_MODULE", "fexum.settings")

channel_layer = get_channel_layer()
github awemulya / kobo-predict / onadata / apps / main / asgi.py View on Github external
import os
from channels.asgi import get_channel_layer

os.environ.setdefault("DJANGO_SETTINGS_MODULE", "onadata.settings.common")

channel_layer = get_channel_layer()