Author neologix
Recipients docs@python, gvanrossum, neologix, vstinner
Date 2013-12-03.21:48:50
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <CAH_1eM2oRDroHKZk7-Bitna1ie6w2NtX3X4ypwhR=KAVCThtjA@mail.gmail.com>
In-reply-to <1386100305.96.0.51037800725.issue19876@psf.upfronthosting.co.za>
Content
> Guido van Rossum added the comment:
>
> I think you're looking for the discussion in issue 19017.
>
> IIRC the conclusion is that not only do you not get the same error everywhere, but you get it at different points -- sometimes register() of a bad FD passes and then [Selector.]select() fails, other times register() of a bad FD fails; when the FD is initially good and then gets closed, sometimes select() may fail, sometimes select() will silently ignore the FD. Sometimes unregister() of a closed FD will return False, sometimes True.
>
> Another consequence is that registering an FD, then closing it, then calling select(), then reopening it may keep reporting events for the FD or not.

Exactly, it's a mess.

> I think these are all things to call out in a section on caveats or common bugs.

What I don't remember was the conclusion: do we want to keep the
current OS-specific behavior, or do we want to try to be tolerant with
misuse?
For example, one possibility would be to ignore errors when
unregistering a file descriptor from epoll: for example, the
selectmodule currently ignore EBADF when unregistering a FD:
"""
        case EPOLL_CTL_DEL:
        /* In kernel versions before 2.6.9, the EPOLL_CTL_DEL
         * operation required a non-NULL pointer in event, even
         * though this argument is ignored. */
        Py_BEGIN_ALLOW_THREADS
        result = epoll_ctl(epfd, op, fd, &ev);
        if (errno == EBADF) {
            /* fd already closed */
            result = 0;
            errno = 0;
        }
"""

IIRC libev and libevent both ignore those errors.

We have to settle on a solution before documenting it.
History
Date User Action Args
2013-12-03 21:48:50neologixsetrecipients: + neologix, gvanrossum, vstinner, docs@python
2013-12-03 21:48:50neologixlinkissue19876 messages
2013-12-03 21:48:50neologixcreate