Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def serve_daphne(self, host, port, **kwargs):
util.ensure_pip("daphne")
import daphne.server
import daphne.cli
self.server_version = daphne.__version__
app_asgi = build_asgi_i(self)
app_daphne = daphne.cli.ASGI3Middleware(app_asgi)
self._server = daphne.server.Server(
app_daphne,
endpoints = ["tcp:port=%d:interface=%s" % (port, host)]
)
self._server.run()
from django.apps import AppConfig
# We import this here to ensure the reactor is installed very early on
# in case other packages accidentally import twisted.internet.reactor
# (e.g. raven does this).
import daphne.server
assert daphne.server # pyflakes doesn't support ignores
class ChannelsConfig(AppConfig):
name = "channels"
verbose_name = "Channels"
def ready(self):
# Do django monkeypatches
from .hacks import monkeypatch_django
monkeypatch_django()