Index: selectmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/selectmodule.c,v retrieving revision 2.68 diff -c -r2.68 selectmodule.c *** selectmodule.c 28 Jul 2002 15:12:10 -0000 2.68 --- selectmodule.c 19 Sep 2002 17:21:11 -0000 *************** *** 39,45 **** #endif #ifdef MS_WINDOWS ! #include #else #ifdef __BEOS__ #include --- 39,45 ---- #endif #ifdef MS_WINDOWS ! #include #else #ifdef __BEOS__ #include *************** *** 269,280 **** --- 269,321 ---- if (omax > max) max = omax; if (emax > max) max = emax; + #ifdef MS_WINDOWS + if (imax == 0 && omax == 0 && emax == 0) { + /* On Windows, select doesn't accept all empty lists. + Simulate the timeout with a Sleep() call. Since Sleep + expects the timeout value in milliseconds, the maximum + timeout will be smaller the the maximum timeout + select() can handle, but it's still more than four + million seconds. */ + long msec; + if (tvp) { + double timeout; + long msec; + timeout = tvp->tv_sec * 1000.0 + \ + tvp->tv_usec / 1000.0; + if (timeout > (double)LONG_MAX) { + PyErr_SetString(PyExc_OverflowError, + "timeout period too long"); + goto finally; + } + msec = (long)timeout; + if (msec == INFINITE) + --msec; + } else { + msec = INFINITE; + } + Py_BEGIN_ALLOW_THREADS + printf("sleep %d\n", msec); + Sleep(msec); + Py_END_ALLOW_THREADS + n = 0; + } else { + Py_BEGIN_ALLOW_THREADS + n = select(max, &ifdset, &ofdset, &efdset, tvp); + Py_END_ALLOW_THREADS + } + #else Py_BEGIN_ALLOW_THREADS n = select(max, &ifdset, &ofdset, &efdset, tvp); Py_END_ALLOW_THREADS + #endif if (n < 0) { + #ifdef MS_WINDOWS + PyErr_SetExcFromWindowsErr(SelectError, WSAGetLastError()); + #else PyErr_SetFromErrno(SelectError); + #endif } else if (n == 0) { /* optimization */