mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
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.
This commit is contained in:
parent
4fa99cdb4c
commit
9a8089b32a
5 changed files with 27 additions and 15 deletions
|
@ -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);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue