This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author yselivanov
Recipients gvanrossum, martius, neologix, vstinner, yselivanov
Date 2015-05-26.16:20:12
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1432657212.39.0.74192376237.issue21998@psf.upfronthosting.co.za>
In-reply-to
Content
> How do other event loops handle fork? Twisted, Tornado, libuv, libev,
libevent, etc.

It looks like using fork() while an event loop is running isn't recommended in any of the above.  If I understand the code correctly, libev & gevent reinitialize loops in the forked process (essentially, you have a new loop).

I think we have the following options:

1. Document that using fork() is not recommended.

2. Detect fork() and re-initialize event loop in the child process (cleaning-up callback queues, re-initializing selectors, creating new self-pipe).

3. Detect fork() and raise a RuntimeError.  Document that asyncio event loop does not support forking at all.

4. The most recent patch by Martin detects the fork() and reinitializes self-pipe and selector (although all FDs are kept in the new selector).  I'm not sure I understand this option.

I'm torn between 2 & 3.  Guido, Victor, Martin, what do you think?
History
Date User Action Args
2015-05-26 16:20:12yselivanovsetrecipients: + yselivanov, gvanrossum, vstinner, neologix, martius
2015-05-26 16:20:12yselivanovsetmessageid: <1432657212.39.0.74192376237.issue21998@psf.upfronthosting.co.za>
2015-05-26 16:20:12yselivanovlinkissue21998 messages
2015-05-26 16:20:12yselivanovcreate