Author neologix
Recipients gvanrossum, martius, neologix, vstinner, yselivanov
Date 2015-02-17.19:16:32
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <CAH_1eM29frts=h52iGrkhzhZvEgOa0W13xk8H8sbMnaJYaBrMA@mail.gmail.com>
In-reply-to <1424182358.75.0.201645146564.issue21998@psf.upfronthosting.co.za>
Content
> @neologix: Would you be ok to add a *private* _at_fork() method to selectors classes in Python 3.4 to fix this issue?

Not really: after fork(), you're hosed anyway:
"""

       Q6  Will closing a file descriptor cause it to be removed from
all epoll sets automatically?

       A6  Yes, but be aware of the following point.  A file
descriptor is a reference to an open file  description
           (see open(2)).  Whenever a descriptor is duplicated via
dup(2), dup2(2), fcntl(2) F_DUPFD, or fork(2), a
           new file descriptor referring to the same open file
description is created.  An  open  file  description
           continues  to  exist  until all file descriptors referring
to it have been closed.  A file descriptor is
           removed from an epoll set only after all the file
descriptors referring  to  the  underlying  open  file
           description  have  been  closed  (or  before  if the
descriptor is explicitly removed using epoll_ctl(2)
           EPOLL_CTL_DEL).  This means that even after a file
descriptor that is part of  an  epoll  set  has  been
           closed,  events may be reported for that file descriptor if
other file descriptors referring to the same
           underlying file description remain open.
"""

What would you do with the selector after fork(): register the FDs in
a new epoll, remove them?

There's no sensible default behavior, and I'd rrather avoid polluting
the code for this.
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.
History
Date User Action Args
2015-02-17 19:16:32neologixsetrecipients: + neologix, gvanrossum, vstinner, yselivanov, martius
2015-02-17 19:16:32neologixlinkissue21998 messages
2015-02-17 19:16:32neologixcreate