mirror of
https://github.com/django/daphne.git
synced 2025-07-10 16:02: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.log import setup_logger
|
||||||
from channels.staticfiles import StaticFilesConsumer
|
from channels.staticfiles import StaticFilesConsumer
|
||||||
from channels.worker import Worker
|
from channels.worker import Worker
|
||||||
|
from channels.signals import worker_ready
|
||||||
|
|
||||||
|
|
||||||
class Command(BaseCommand):
|
class Command(BaseCommand):
|
||||||
|
@ -53,12 +54,14 @@ class Command(BaseCommand):
|
||||||
callback = self.consumer_called
|
callback = self.consumer_called
|
||||||
# Run the worker
|
# Run the worker
|
||||||
try:
|
try:
|
||||||
Worker(
|
worker = Worker(
|
||||||
channel_layer=self.channel_layer,
|
channel_layer=self.channel_layer,
|
||||||
callback=callback,
|
callback=callback,
|
||||||
only_channels=options.get("only_channels", None),
|
only_channels=options.get("only_channels", None),
|
||||||
exclude_channels=options.get("exclude_channels", None),
|
exclude_channels=options.get("exclude_channels", None),
|
||||||
).run()
|
)
|
||||||
|
worker_ready.send(sender=worker)
|
||||||
|
worker.run()
|
||||||
except KeyboardInterrupt:
|
except KeyboardInterrupt:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
|
@ -4,6 +4,7 @@ from django.dispatch import Signal
|
||||||
|
|
||||||
consumer_started = Signal(providing_args=["environ"])
|
consumer_started = Signal(providing_args=["environ"])
|
||||||
consumer_finished = Signal()
|
consumer_finished = Signal()
|
||||||
|
worker_ready = Signal()
|
||||||
|
|
||||||
# Connect connection closer to consumer finished as well
|
# Connect connection closer to consumer finished as well
|
||||||
consumer_finished.connect(close_old_connections)
|
consumer_finished.connect(close_old_connections)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user