Re: [Twisted-Python] epoll keep sharing state between process even after fork.
On 03:46 pm, grindizer@gmail.com wrote:
Hi everybody
I a came across a surprising problem when using the epoll based reactor. (ticket here https://twistedmatrix.com/trac/ticket/6796)
As you can see on the ticket, the epoll object seems to share some state even after fork.
[snip]
- Using spawnProcess as mentioned in the ticket comment, is not an option too, in my case, I need to share some state between the main process and subprocess. (I have on object in main process space that I want to inherit in all subprocess)
This doesn't really explain why you can't use `spawnProcess`. There are other ways to share state between processes. Perhaps if you describe the object you have someone can suggest a way to share it that will still satisfy your requirements without requiring that you use the `multiprocessing` module.
Jean-Paul
Hi. For the moment I share a factory object, but it's the underlying "protocol class" that is really needed. The code takes a factory object, and then launch a set of worker/process. when a connection is made on the parent process, the socket handler will be sent to one of the process (using sendmsg), the process will then run reactor.adoptStreamConnection and this is when we need the protocol class. There is an example of what I would like to achieve here https://github.com/Grindizer/scaletix the example works with select or poll reactor. with spawnProcess I guess the child process will need to somehow import the factory class and should be given the way to instanciate it ? isn't it ? I don't know other way to do it actually ? thankx again.
participants (1)
-
Flint