Reputation: 143
I have a well working websocket implementation using python's tornado framework, used as a backend, working well on single tornado processes. Although I am trying, I cannot reserve websocket client connections between multiple processes.
I am currently adding client instances to a module's dictionary object, which is not easily accessible from other processes.
How should someone preserve a class instance between multiple processes in python (more specifically, tornado)?
Upvotes: 2
Views: 2696
Reputation: 31161
You shouldn't try to share objects between processes. Just don't do it.
If your use case is that one process stopped for any reason, have the client handle the closure by reconnecting. The connection will be routed to another, running Tornado process.
If your use case is to share a message with other Tornado processes, have a think about your network topology: You might send the message to a new parent node that distributes the message back to all Tornado instances (including the original Tornado process).
The ZMQ library and documentation are wonderful resources and will give you some ideas.
Upvotes: 0