Share unpickleable object across processes
Israel Brewster
israel at ravnalaska.net
Thu Nov 2 16:35:23 EDT 2017
On Nov 2, 2017, at 12:30 PM, Chris Angelico <rosuav at gmail.com> wrote:
>
> On Fri, Nov 3, 2017 at 5:54 AM, Israel Brewster <israel at ravnalaska.net> wrote:
>> I have a Flask/UWSGI web app that serves up web socket connections. When a web socket connection is created, I want to store a reference to said web socket so I can do things like write messages to every connected socket/disconnect various sockets/etc. UWSGI, however, launches multiple child processes which handle incoming connections, so the data structure that stores the socket connections needs to be shared across all said processes. How can I do this?
>>
>
> You're basically going to need to have a single process that manages
> all the socket connections. Do you actually NEED multiple processes to
> do your work? If you can do it with multiple threads in a single
> process, you'll be able to share your socket info easily. Otherwise,
> you could have one process dedicated to managing the websockets, and
> all the others message that process saying "please send this to all
> processes".
Ok, that makes sense, but again: it's UWSGI that creates the processes, not me. I'm not creating *any* processes or threads. Aside from telling UWSGI to only use a single worker, I have no control over what happens where. But maybe that's what I need to do?
>
> ChrisA
> --
> https://mail.python.org/mailman/listinfo/python-list
More information about the Python-list
mailing list