diff options
author | Victor Stinner <victor.stinner@haypocalc.com> | 2011-07-01 11:50:09 (GMT) |
---|---|---|
committer | Victor Stinner <victor.stinner@haypocalc.com> | 2011-07-01 11:50:09 (GMT) |
commit | 48b1ce5519623e83c5910453babef99ffdce3e23 (patch) | |
tree | 5feb53a9b18d248188fda9d20a6e5aea3f722574 /Modules/timemodule.c | |
parent | 210e7ca032d51b8368359c02ad505dbd5f633cc9 (diff) | |
download | cpython-48b1ce5519623e83c5910453babef99ffdce3e23.zip cpython-48b1ce5519623e83c5910453babef99ffdce3e23.tar.gz cpython-48b1ce5519623e83c5910453babef99ffdce3e23.tar.bz2 |
Issue #12462: time.sleep() now calls immediatly the (Python) signal handler if
it is interrupted by a signal, instead of having to wait until the next
instruction.
Patch reviewed by Antoine Pitrou.
Diffstat (limited to 'Modules/timemodule.c')
-rw-r--r-- | Modules/timemodule.c | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/Modules/timemodule.c b/Modules/timemodule.c index 2b86bcb..75aa8b6 100644 --- a/Modules/timemodule.c +++ b/Modules/timemodule.c @@ -915,23 +915,28 @@ floatsleep(double secs) #if defined(HAVE_SELECT) && !defined(__EMX__) struct timeval t; double frac; + int err; + frac = fmod(secs, 1.0); secs = floor(secs); t.tv_sec = (long)secs; t.tv_usec = (long)(frac*1000000.0); Py_BEGIN_ALLOW_THREADS - if (select(0, (fd_set *)0, (fd_set *)0, (fd_set *)0, &t) != 0) { + err = select(0, (fd_set *)0, (fd_set *)0, (fd_set *)0, &t); + Py_END_ALLOW_THREADS + if (err != 0) { #ifdef EINTR - if (errno != EINTR) { -#else - if (1) { + if (errno == EINTR) { + if (PyErr_CheckSignals()) + return -1; + } + else #endif - Py_BLOCK_THREADS + { PyErr_SetFromErrno(PyExc_IOError); return -1; } } - Py_END_ALLOW_THREADS #elif defined(__WATCOMC__) && !defined(__QNX__) /* XXX Can't interrupt this sleep */ Py_BEGIN_ALLOW_THREADS |