mirror of
https://github.com/python/cpython.git
synced 2025-08-31 14:07:50 +00:00
Issue #22043: time.monotonic() is now always available
threading.Lock.acquire(), threading.RLock.acquire() and socket operations now use a monotonic clock, instead of the system clock, when a timeout is used.
This commit is contained in:
parent
9bb758cee7
commit
ae58649721
17 changed files with 226 additions and 176 deletions
|
@ -57,7 +57,7 @@ acquire_timed(PyThread_type_lock lock, PY_TIMEOUT_T microseconds)
|
|||
|
||||
|
||||
if (microseconds > 0) {
|
||||
_PyTime_gettimeofday(&endtime);
|
||||
_PyTime_monotonic(&endtime);
|
||||
endtime.tv_sec += microseconds / (1000 * 1000);
|
||||
endtime.tv_usec += microseconds % (1000 * 1000);
|
||||
}
|
||||
|
@ -83,7 +83,7 @@ acquire_timed(PyThread_type_lock lock, PY_TIMEOUT_T microseconds)
|
|||
/* If we're using a timeout, recompute the timeout after processing
|
||||
* signals, since those can take time. */
|
||||
if (microseconds > 0) {
|
||||
_PyTime_gettimeofday(&curtime);
|
||||
_PyTime_monotonic(&curtime);
|
||||
microseconds = ((endtime.tv_sec - curtime.tv_sec) * 1000000 +
|
||||
(endtime.tv_usec - curtime.tv_usec));
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue