Add worker_ready signal

This commit is contained in:
Andrew Godwin 2016-07-22 21:51:28 -04:00
parent a4c8602ea1
commit b76bf3c1cc
2 changed files with 6 additions and 2 deletions

View File

@ -7,6 +7,7 @@ from channels import DEFAULT_CHANNEL_LAYER, channel_layers
from channels.log import setup_logger
from channels.staticfiles import StaticFilesConsumer
from channels.worker import Worker
from channels.signals import worker_ready
class Command(BaseCommand):
@ -53,12 +54,14 @@ class Command(BaseCommand):
callback = self.consumer_called
# Run the worker
try:
Worker(
worker = Worker(
channel_layer=self.channel_layer,
callback=callback,
only_channels=options.get("only_channels", None),
exclude_channels=options.get("exclude_channels", None),
).run()
)
worker_ready.send(sender=worker)
worker.run()
except KeyboardInterrupt:
pass

View File

@ -4,6 +4,7 @@ from django.dispatch import Signal
consumer_started = Signal(providing_args=["environ"])
consumer_finished = Signal()
worker_ready = Signal()
# Connect connection closer to consumer finished as well
consumer_finished.connect(close_old_connections)