Tuesday, April 25, 2017

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

Dear Andrew,

thank you for advice. Now I am starting implementing ASGI worked based on one included in Channels. I would like to take a look at example of how to create and use single-reader channels properly, so I took Channels, asgi_redis and Daphne code base and did not found any place where such channels are created. In particular, I hoped to find the place where Daphne creates `http.request.body_channel` to handle large HTTP requests. To my surprise I did not found any `body_channel` mentions in the Daphne code except a single test, which simply checks the message for `body_channel` optional field. Do I miss something, or Daphne simply does not implement this concept and therefor cannot handle large requests sequentially by chunking them?

воскресенье, 19 марта 2017 г., 21:18:07 UTC+3 пользователь Andrew Godwin написал:
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 <pro...@gmail.com> 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 django-users...@googlegroups.com.
To post to this group, send email to django...@googlegroups.com.
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 django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
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/f570799c-a6d7-4a15-bdb2-68b08cbe7c66%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment