diff -r 350eb1ca561a Lib/asyncore.py --- a/Lib/asyncore.py Mon Mar 30 03:57:14 2015 +0200 +++ b/Lib/asyncore.py Mon Mar 30 04:12:10 2015 +0200 @@ -141,10 +141,7 @@ def poll(timeout=0.0, map=None): time.sleep(timeout) return - try: - r, w, e = select.select(r, w, e, timeout) - except InterruptedError: - return + r, w, e = select.select(r, w, e, timeout) for fd in r: obj = map.get(fd) diff -r 350eb1ca561a Lib/selectors.py --- a/Lib/selectors.py Mon Mar 30 03:57:14 2015 +0200 +++ b/Lib/selectors.py Mon Mar 30 04:12:10 2015 +0200 @@ -310,10 +310,7 @@ class SelectSelector(_BaseSelectorImpl): def select(self, timeout=None): timeout = None if timeout is None else max(timeout, 0) ready = [] - try: - r, w, _ = self._select(self._readers, self._writers, [], timeout) - except InterruptedError: - return ready + r, w, _ = self._select(self._readers, self._writers, [], timeout) r = set(r) w = set(w) for fd in r | w: diff -r 350eb1ca561a Modules/selectmodule.c --- a/Modules/selectmodule.c Mon Mar 30 03:57:14 2015 +0200 +++ b/Modules/selectmodule.c Mon Mar 30 04:12:10 2015 +0200 @@ -193,29 +193,31 @@ select_select(PyObject *self, PyObject * #endif /* SELECT_USES_HEAP */ PyObject *ifdlist, *ofdlist, *efdlist; PyObject *ret = NULL; - PyObject *tout = Py_None; + PyObject *timeout_obj = Py_None; fd_set ifdset, ofdset, efdset; struct timeval tv, *tvp; int imax, omax, emax, max; int n; + _PyTime_t deadline, timeout; /* convert arguments */ if (!PyArg_UnpackTuple(args, "select", 3, 4, - &ifdlist, &ofdlist, &efdlist, &tout)) + &ifdlist, &ofdlist, &efdlist, &timeout_obj)) return NULL; - if (tout == Py_None) + if (timeout_obj == Py_None) tvp = (struct timeval *)0; else { - _PyTime_t ts; - - if (_PyTime_FromSecondsObject(&ts, tout, _PyTime_ROUND_CEILING) < 0) { - PyErr_SetString(PyExc_TypeError, - "timeout must be a float or None"); + if (_PyTime_FromSecondsObject(&timeout, timeout_obj, + _PyTime_ROUND_CEILING) < 0) { + if (PyErr_ExceptionMatches(PyExc_TypeError)) { + PyErr_SetString(PyExc_TypeError, + "timeout must be a float or None"); + } return NULL; } - if (_PyTime_AsTimeval(ts, &tv, _PyTime_ROUND_CEILING) == -1) + if (_PyTime_AsTimeval(timeout, &tv, _PyTime_ROUND_CEILING) == -1) return NULL; if (tv.tv_sec < 0) { PyErr_SetString(PyExc_ValueError, "timeout must be non-negative"); @@ -253,9 +255,31 @@ select_select(PyObject *self, PyObject * if (omax > max) max = omax; if (emax > max) max = emax; - Py_BEGIN_ALLOW_THREADS - n = select(max, &ifdset, &ofdset, &efdset, tvp); - Py_END_ALLOW_THREADS + if (tvp) + deadline = _PyTime_GetMonotonicClock() + timeout; + + do { + Py_BEGIN_ALLOW_THREADS + errno = 0; + n = select(max, &ifdset, &ofdset, &efdset, tvp); + Py_END_ALLOW_THREADS + + if (errno != EINTR) + break; + + /* select() was interrupted by a signal */ + if (PyErr_CheckSignals()) + goto finally; + + if (tvp) { + timeout = deadline - _PyTime_GetMonotonicClock(); + if (timeout <= 0) { + n = 0; + break; + } + _PyTime_AsTimeval_noraise(timeout, &tv, _PyTime_ROUND_CEILING); + } + } while (1); #ifdef MS_WINDOWS if (n == SOCKET_ERROR) {