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 sbt
Recipients giampaolo.rodola, jcea, pitrou, sbt, trent
Date 2012-12-07.18:50:50
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
It seems that the return code of WSAPoll() does not include the count of array items with revents == POLLNVAL.  In the case where all of them are POLLNVAL, instead of returning 0 (which usually indicates a timeout) it returns -1 and WSAGetLastError() == WSAENOTSOCK.

This does not match the MSDN documentation which claims that the return code is the number of descriptors for which revents is non-zero.  But it arguably does agree with the FreeBSD and MacOSX man pages which say that it returns the number of descriptors that are "ready for I/O".

BTW, the implementation of select_poll() assumes that the return code of poll() (if non-negative) is equal to the number of non-zero revents fields.  But select_have_broken_poll() considers a MacOSX poll() implementation to be good even in cases where this assumption is not true:

static int select_have_broken_poll(void)
    int poll_test;
    int filedes[2];
    struct pollfd poll_struct = { 0, POLLIN|POLLPRI|POLLOUT, 0 };
    if (pipe(filedes) < 0) {
        return 1;
    poll_struct.fd = filedes[0];
    poll_test = poll(&poll_struct, 1, 0);
    if (poll_test < 0) {
        return 1;
    } else if (poll_test == 0 && poll_struct.revents != POLLNVAL) {
        return 1;
    return 0;

Note that select_have_broken_poll() == FALSE if poll_test == 0 and poll_struct.revents == POLLNVAL.
Date User Action Args
2012-12-07 18:50:51sbtsetrecipients: + sbt, jcea, pitrou, giampaolo.rodola, trent
2012-12-07 18:50:51sbtsetmessageid: <>
2012-12-07 18:50:50sbtlinkissue16507 messages
2012-12-07 18:50:50sbtcreate