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 vstinner
Recipients gvanrossum, martius, neologix, vstinner, yselivanov
Date 2015-02-17.21:27:13
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <CAMpsgwaipJkfktbYWBmsaP_BeO4KZiBE2Hb0Xh_GCrek6-WD_A@mail.gmail.com>
In-reply-to <CAH_1eM29frts=h52iGrkhzhZvEgOa0W13xk8H8sbMnaJYaBrMA@mail.gmail.com>
Content
2015-02-17 20:16 GMT+01:00 Charles-François Natali <report@bugs.python.org>:
> 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
attribute.
History
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