Friday, October 27, 2017

Re: How to start and stopp threads in Django/Channels while using websockets

You can't do this from inside Django right now - the background workers were designed to solve this problem.

Andrew

On Fri, Oct 27, 2017 at 6:26 AM, 'matrix1900' via Django users <django-users@googlegroups.com> wrote:
Hi ,


in my project, I want to use Django and Web sockets. The Solution is --> Channels.
But I have a problem. How can I start and stop an external long running thread from inside  Django.  I don't want to start an separate worker via console. I want to start it inside Django (Maybe in Consumer.py)
Concept:
1. The thread should be started, when a message is received via web socket. 
2. In the thread I stream data to the sender of the websocket message until I get a stop message via web socket from that sender.

How can I realize that? In Channels are Background Worker available. But I am not sure if it is the right mechanism for me?  Maybe Django is not the right tool for my problem?  

--
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/3844f448-6d31-4656-b014-a69212d9f1f2%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/CAFwN1uoPAz%3DAR60%3D6DN1b%3D80U6JLsES6xumQ5Y5ODaC_H-kfUg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment