mirror of
https://github.com/django/daphne.git
synced 2025-04-20 08:42:18 +03:00
Add worker_ready signal
This commit is contained in:
parent
a4c8602ea1
commit
b76bf3c1cc
|
@ -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
|
||||
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue
Block a user