diff options
author | Victor Stinner <victor.stinner@gmail.com> | 2015-03-20 00:42:20 (GMT) |
---|---|---|
committer | Victor Stinner <victor.stinner@gmail.com> | 2015-03-20 00:42:20 (GMT) |
commit | 9a8089b32adee874caefbe2a96096998625c5a78 (patch) | |
tree | bf91050cbe41ad7811a975acc3bab8ed4ee97c02 /Modules/timemodule.c | |
parent | 4fa99cdb4c5f53d6fa86ef223ae613cb1a8783f8 (diff) | |
download | cpython-9a8089b32adee874caefbe2a96096998625c5a78.zip cpython-9a8089b32adee874caefbe2a96096998625c5a78.tar.gz cpython-9a8089b32adee874caefbe2a96096998625c5a78.tar.bz2 |
Issue #23646: Enhance precision of time.sleep() and socket timeout when
interrupted by a signal
Add a new _PyTime_AddDouble() function and remove _PyTime_ADD_SECONDS() macro.
The _PyTime_ADD_SECONDS only supported an integer number of seconds, the
_PyTime_AddDouble() has subsecond resolution.
Diffstat (limited to 'Modules/timemodule.c')
-rw-r--r-- | Modules/timemodule.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/Modules/timemodule.c b/Modules/timemodule.c index 179c33f..204626e 100644 --- a/Modules/timemodule.c +++ b/Modules/timemodule.c @@ -1399,14 +1399,14 @@ floatsleep(double secs) #endif _PyTime_monotonic(&deadline); - _PyTime_ADD_SECONDS(deadline, secs); + _PyTime_AddDouble(&deadline, secs, _PyTime_ROUND_UP); do { #ifndef MS_WINDOWS frac = fmod(secs, 1.0); secs = floor(secs); timeout.tv_sec = (long)secs; - timeout.tv_usec = (long)(frac*1000000.0); + timeout.tv_usec = (long)(frac*1e6); Py_BEGIN_ALLOW_THREADS err = select(0, (fd_set *)0, (fd_set *)0, (fd_set *)0, &timeout); |