I'm using Channels v2. I want to integrate long-polling into my project.

The only consumer I see in the documentation for http long polling is the 
AsyncHttpConsumer 
<https://channels.readthedocs.io/en/2.x/topics/consumers.html#asynchttpconsumer>
.

The code I need to run in my handle function is not asynchronous. It 
connects to another device on the network using a library that is not 
asynchronous. From what I understand, this will cause the event loop to 
block, which is bad. Client requests will be handled one at a time.

Can I run my handler synchronously, in a thread somehow?

I asked the same question 
here: https://stackoverflow.com/q/66055657/6423456, but so far got no 
responses.

I quickly wrote a subclass of SyncConsumer that works, but:


   1. I can't imagine that everyone is doing this - there must be an easier 
   way
   2. The disconnect() method is not called until after the handle() method 
   is done running, so from what I can tell, there's no way to interrupt the 
   handle method early (unless the handle method kicks off its own thread or 
   something)

I posted the code for the subclass of SyncConsumer as an answer to my 
stackoverflow question, but I'm hoping there's a better, easier way to do 
this.

-- 
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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/6f40e058-b330-40bd-980b-4569b2975375n%40googlegroups.com.

Reply via email to