mirror of
https://github.com/django/daphne.git
synced 2025-04-21 01:02:06 +03:00
Warn when trying to use runworker with in memory layer
This commit is contained in:
parent
b18975e607
commit
61b8940e99
|
@ -75,6 +75,10 @@ class ChannelLayerWrapper(object):
|
|||
def __str__(self):
|
||||
return "%s (%s)" % (self.alias, name_that_thing(self.channel_layer))
|
||||
|
||||
def local_only(self):
|
||||
# TODO: Can probably come up with a nicer check?
|
||||
return "inmemory" in self.channel_layer.__class__.__module__
|
||||
|
||||
|
||||
def get_channel_layer(alias="default"):
|
||||
"""
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
from __future__ import unicode_literals
|
||||
|
||||
from django.core.management import BaseCommand
|
||||
from django.core.management import BaseCommand, CommandError
|
||||
from channels import channel_layers, DEFAULT_CHANNEL_LAYER
|
||||
from channels.log import setup_logger
|
||||
from channels.worker import Worker
|
||||
|
@ -13,6 +13,12 @@ class Command(BaseCommand):
|
|||
self.verbosity = options.get("verbosity", 1)
|
||||
self.logger = setup_logger('django.channels', self.verbosity)
|
||||
self.channel_layer = channel_layers[DEFAULT_CHANNEL_LAYER]
|
||||
# Check that handler isn't inmemory
|
||||
if self.channel_layer.local_only():
|
||||
raise CommandError(
|
||||
"You cannot span multiple processes with the in-memory layer. " +
|
||||
"Change your settings to use a cross-process channel layer."
|
||||
)
|
||||
# Check a handler is registered for http reqs
|
||||
self.channel_layer.registry.check_default()
|
||||
# Launch a worker
|
||||
|
|
Loading…
Reference in New Issue
Block a user