mirror of
https://github.com/django/daphne.git
synced 2025-06-05 21:53:11 +03:00
Make the location of channels in INSTALLED_APPS not matter
This commit is contained in:
parent
7cfb3139dd
commit
6e91ea0040
|
@ -12,9 +12,7 @@ channel_backends = BackendManager(
|
|||
})
|
||||
)
|
||||
|
||||
# Ensure monkeypatching
|
||||
from .hacks import monkeypatch_django
|
||||
monkeypatch_django()
|
||||
default_app_config = 'channels.apps.ChannelsConfig'
|
||||
|
||||
# Promote channel to top-level (down here to avoid circular import errs)
|
||||
from .channel import Channel, Group
|
||||
|
|
11
channels/apps.py
Normal file
11
channels/apps.py
Normal file
|
@ -0,0 +1,11 @@
|
|||
from django.apps import AppConfig
|
||||
|
||||
class ChannelsConfig(AppConfig):
|
||||
|
||||
name = "channels"
|
||||
verbose_name = "Channels"
|
||||
|
||||
def ready(self):
|
||||
# Do django monkeypatches
|
||||
from .hacks import monkeypatch_django
|
||||
monkeypatch_django()
|
|
@ -19,6 +19,11 @@ def monkeypatch_django():
|
|||
# Allow ResponseLater to propagate above handler
|
||||
BaseHandler.old_handle_uncaught_exception = BaseHandler.handle_uncaught_exception
|
||||
BaseHandler.handle_uncaught_exception = new_handle_uncaught_exception
|
||||
# Ensure that the staticfiles version of runserver bows down to us
|
||||
# This one is particularly horrible
|
||||
from django.contrib.staticfiles.management.commands.runserver import Command as StaticRunserverCommand
|
||||
from .management.commands.runserver import Command as RunserverCommand
|
||||
StaticRunserverCommand.__bases__ = (RunserverCommand, )
|
||||
|
||||
|
||||
def new_handle_uncaught_exception(self, request, resolver, exc_info):
|
||||
|
|
|
@ -30,6 +30,10 @@ class Command(RunserverCommand):
|
|||
worker = WorkerThread(self.channel_backend)
|
||||
worker.daemon = True
|
||||
worker.start()
|
||||
# Note that this is the right one on the console
|
||||
self.stdout.write("Worker thread running, channels enabled")
|
||||
if self.channel_backend.local_only:
|
||||
self.stdout.write("Local channel backend detected, no remote channels support")
|
||||
# Run the rest
|
||||
return super(Command, self).run(*args, **options)
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user