[issue21998] asyncio: a new self-pipe should be created in the child process after fork

Guido van Rossum report at bugs.python.org
Mon Sep 15 01:45:33 CEST 2014


Guido van Rossum added the comment:

Actually I expect that if you share an event loop across different processes via form, everything's a mess -- whenever a FD becomes ready, won't both the parent and the child be woken up?  Then both would attempt to read from it.  One would probably get EWOULDBLOCK (assuming all FDs are actually in non-blocking mode) but it would still be a mess.  The specific mess for the self-pipe would be that the race condition it's intended to solve might come back.

It's possible that some polling syscall might have some kind of protection against forking, but the Python data structures that map FDs to handlers don't know that, so it would still be a mess.

Pretty much the only thing you should expect to be able to do safely after forking is closing the event loop -- and I'm not even 100% sure that that's safe (I don't know what happens to a forked executor).

Is there a use case for sharing an event loop across forking?

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue21998>
_______________________________________


More information about the Python-bugs-list mailing list