Author vstinner
Recipients gvanrossum, martius, neologix, vstinner, yselivanov
Date 2015-02-17.21:27:13
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
In-reply-to <>
2015-02-17 20:16 GMT+01:00 Charles-Fran├žois Natali <>:
> What would you do with the selector after fork(): register the FDs in
> a new epoll, remove them?

See the patch:

+        def _at_fork(self):
+            # don't unregister file descriptors: epoll is still shared with
+            # the parent process
+            self._epoll = select.epoll()
+            for key in self._fd_to_key.values():
+                self._register(key)

EpollSelector._at_fork() does nothing on the current epoll object,
create a new epoll object and register again all file descriptor.

Hum, I should maybe close explicitly the old epoll object.

> There's no sensible default behavior, and I'd rrather avoid polluting
> the code for this.

What is wrong with the proposed patch?

> If asyncio wants to support this, it can create a new selector and
> re-register everything it wants manually: there's a Selector.get_map()
> exposing all that's needed.

If possible, I would prefer to implement "at fork" in the selectors
module directly, the selectors module has a better knowledge of
seletors. For example, asyncio is not aware of the selector._epoll
Date User Action Args
2015-02-17 21:27:13vstinnersetrecipients: + vstinner, gvanrossum, neologix, yselivanov, martius
2015-02-17 21:27:13vstinnerlinkissue21998 messages
2015-02-17 21:27:13vstinnercreate