[uWSGI] How to get and store a websocket session?

timothy lee timlee246 at yahoo.com
Tue Apr 21 07:06:33 CEST 2015


Ah, I see. Thank you for help. 


     On Monday, April 20, 2015 9:37 PM, Roberto De Ioris <roberto at unbit.it> wrote:
   

 
> I see. The thing is is that I have another greenlet running that is
> listening through a zeromq port. And depending on what messages I get from
> it, I need to send a message to a certain client, and the server can have
> many clients connected to it. So the only way I can think of to do this is
> to store the websocket session in a dictionary so I can look up which
> client to send a message to.  How can I accomplish this if I can't do it
> the way my example did? 
>


the rule is that a different context (thread, process, greenlet) cannot
access the request/response session of another one. This enforces
transparent support for multiple paradigms.

The common approach is telling the greenlet/process/thread (once the
websocket session is established) to wait for some event (redis is a easy
way to accomplish it, but i suppose you can create a zeromq channel too).

When the "external" greenlet has something to send it simply enqueue a
message back to the channel of the right request context.

With this technique you can support multiple greenlet in multiple
processes too.

-- 
Roberto De Ioris
http://unbit.com
_______________________________________________
uWSGI mailing list
uWSGI at lists.unbit.it
http://lists.unbit.it/cgi-bin/mailman/listinfo/uwsgi


  
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.unbit.it/pipermail/uwsgi/attachments/20150421/ca345e7a/attachment.html>


More information about the uWSGI mailing list