Python channels.routing.ProtocolTypeRouter() Examples

The following are 3 code examples of channels.routing.ProtocolTypeRouter(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module channels.routing , or try the search function .
Example #1
Source File: asgi.py    From cjworkbench with GNU Affero General Public License v3.0 6 votes vote down vote up
def create_application() -> ProtocolTypeRouter:
    """Create an ASGI application."""
    # Load static modules on startup.
    #
    # This means starting a kernel and validating all static modules. There are
    # two good reasons to load during startup:
    #
    # 1. In dev mode, this reports errors in modules ASAP -- during startup
    # 2. In production, this import line costs time -- better to incur that
    #    cost during startup than to incur it when responding to some random
    #    request.
    cjwstate.modules.init_module_system()
    if not settings.I_AM_TESTING:
        # Only the test environment, Django runs migrations itself. We can't
        # use MODULE_REGISTRY until it migrates.
        MODULE_REGISTRY.all_latest()

    return ProtocolTypeRouter(
        {
            "websocket": AuthMiddlewareStack(
                SetCurrentLocaleAsgiMiddleware(create_url_router())
            )
        }
    ) 
Example #2
Source File: pytest.py    From openwisp-controller with GNU General Public License v3.0 5 votes vote down vote up
def test_routing(self):
        from openwisp_controller.geo.channels.routing import channel_routing

        assert isinstance(channel_routing, ProtocolTypeRouter) 
Example #3
Source File: test_channels.py    From django-loci with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def test_routing(self):
        from django_loci.channels.routing import channel_routing

        assert isinstance(channel_routing, ProtocolTypeRouter)