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
|
@ -680,7 +680,7 @@ internal_select(PySocketSockObject *s, int writing)
|
|||
double interval = s->sock_timeout; \
|
||||
int has_timeout = s->sock_timeout > 0.0; \
|
||||
if (has_timeout) { \
|
||||
_PyTime_gettimeofday(&now); \
|
||||
_PyTime_monotonic(&now); \
|
||||
deadline = now; \
|
||||
_PyTime_ADD_SECONDS(deadline, s->sock_timeout); \
|
||||
} \
|
||||
|
@ -691,7 +691,7 @@ internal_select(PySocketSockObject *s, int writing)
|
|||
if (!has_timeout || \
|
||||
(!CHECK_ERRNO(EWOULDBLOCK) && !CHECK_ERRNO(EAGAIN))) \
|
||||
break; \
|
||||
_PyTime_gettimeofday(&now); \
|
||||
_PyTime_monotonic(&now); \
|
||||
interval = _PyTime_INTERVAL(now, deadline); \
|
||||
} \
|
||||
} \
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue