mirror of
https://github.com/django/daphne.git
synced 2025-10-18 17:44:16 +03:00
20 lines
625 B
Python
20 lines
625 B
Python
class Worker(object):
|
|
"""
|
|
A "worker" process that continually looks for available messages to run
|
|
and runs their consumers.
|
|
"""
|
|
|
|
def __init__(self, channel_layer):
|
|
self.channel_layer = channel_layer
|
|
|
|
def run(self):
|
|
"""
|
|
Tries to continually dispatch messages to consumers.
|
|
"""
|
|
|
|
channels = self.channel_layer.registry.all_channel_names()
|
|
while True:
|
|
channel, message = self.channel_layer.receive_many(channels)
|
|
consumer = self.channel_layer.registry.consumer_for_channel(channel)
|
|
consumer(**message)
|