Message236149
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. |
|
Date |
User |
Action |
Args |
2015-02-17 21:27:13 | vstinner | set | recipients:
+ vstinner, gvanrossum, neologix, yselivanov, martius |
2015-02-17 21:27:13 | vstinner | link | issue21998 messages |
2015-02-17 21:27:13 | vstinner | create | |
|