Quantcast

Attach consumer to dynamically created single-reader channel (Django Channels)

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Attach consumer to dynamically created single-reader channel (Django Channels)

Alexander Prokhorov
Dear Colleagues,

I am playing with Channels for some time already.

Now, I am trying to establish "sticky" channel to one of available workers. I thought I can create single-reader channel from consumer and somehow fix the routing to make this particular worker handle this single-reader channel. I can use

channels.channel_layers[channels.DEFAULT_CHANNEL_LAYER].new_channel("my_exclusive_channel?")

in consumer core to create single-reader channel, but I cannot understand how to setup routing properly in such case. I tried to implement router object from scratch, but as I see its method `channel_names` invoked only one time per worker. In other words, the problems reduces to the question if it is possible to attach some consumer to dynamically created single-reader channel.


--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/be4c787f-1abc-4ece-8b74-ad13ce7180eb%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Attach consumer to dynamically created single-reader channel (Django Channels)

Andrew Godwin-3
Workers can't dynamically change their channels during runtime, but you can tell workers to only run specific channels in one of two ways:

 - Have different routing configurations and different settings files that point to each for the two worker groups
 - Use the --only-channels and --exclude-channels arguments to runworker to restrict which channels it will process.

You can still only do this once at the start of the application, though. There's no way to dynamically vary what a worker wants at runtime because of how the Channels framework is written and integrated into Django; you'd have to do your own ASGI worker class from scratch if you wanted that.

Andrew

On Sun, Mar 19, 2017 at 5:57 AM, Alexander Prokhorov <[hidden email]> wrote:
Dear Colleagues,

I am playing with Channels for some time already.

Now, I am trying to establish "sticky" channel to one of available workers. I thought I can create single-reader channel from consumer and somehow fix the routing to make this particular worker handle this single-reader channel. I can use

channels.channel_layers[channels.DEFAULT_CHANNEL_LAYER].new_channel("my_exclusive_channel?")

in consumer core to create single-reader channel, but I cannot understand how to setup routing properly in such case. I tried to implement router object from scratch, but as I see its method `channel_names` invoked only one time per worker. In other words, the problems reduces to the question if it is possible to attach some consumer to dynamically created single-reader channel.


--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/be4c787f-1abc-4ece-8b74-ad13ce7180eb%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAFwN1uot2foSc-9N7yVnBGuqwykn3k1vruAxX3wpF0p1JC%3Dr-A%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Loading...