This issue tracker has been migrated to GitHub ,
and is currently read-only.
For more information,
see the GitHub FAQs in the Python's Developer Guide.
Created on 2019年01月15日 17:54 by ido k, last changed 2022年04月11日 14:59 by admin. This issue is now closed.
| Files | ||||
|---|---|---|---|---|
| File name | Uploaded | Description | Edit | |
| wrong_wait_behaviour.py | ido k, 2019年01月15日 17:54 | |||
| Messages (7) | |||
|---|---|---|---|
| msg333718 - (view) | Author: ido k (ido k) | Date: 2019年01月15日 17:54 | |
Happen on ubuntu Opening two threads - one thread alternate system date The seconds waits for 60 seconds. joining both threads. The execution should take at least 60 seconds. Takes less then 15 seconds. Any work around? |
|||
| msg333719 - (view) | Author: STINNER Victor (vstinner) * (Python committer) | Date: 2019年01月15日 17:57 | |
Python 3 uses a monotonic clock to implement timeouts, such clock is not affected by system clock changes *on purpose*. See time.monotonic() and PEP 418: https://docs.python.org/dev/library/time.html#time.monotonic https://www.python.org/dev/peps/pep-0418/ Relying on the system clock can cause severe bugs. I suggest to close this issue as "not a bug". |
|||
| msg333720 - (view) | Author: ido k (ido k) | Date: 2019年01月15日 18:03 | |
thanks for the comment please look at the code. i use wait on event for 60 seconds. the wait timed out in less than 60 seconds... why this is not a bug? |
|||
| msg333796 - (view) | Author: Pablo Galindo Salgado (pablogsal) * (Python committer) | Date: 2019年01月16日 22:15 | |
I think this is becase at the end, the threading code calls sem_timedwait(thelock, &ts) where &ts is the timespect structure. The manpage of sem_timedwait says: ... The timeout shall expire when the absolute time specified by abs_timeout passes, as measured by the clock on which timeouts are based (that is, when the value of that clock equals or exceeds abs_timeout), or if the absolute time specified by abs_timeout has already been passed at the time of the call. If the Timers option is supported, the timeout shall be based on the CLOCK_REALTIME clock. If the Timers option is not supported, the timeout shall be based on the system clock as returned by the time() function. The resolution of the timeout shall be the resolution of the clock on which it is based. The timespec data type is defined as a structure in the <time.h> header. So I assume this is using the system clock, so is affected by the date. |
|||
| msg333811 - (view) | Author: ido k (ido k) | Date: 2019年01月17日 01:33 | |
thanks @pablogsal. looks like duplicate of bugs.python.org/issue23428 It seems like i cant trust the threading wait function and need to use busy waiting. |
|||
| msg333842 - (view) | Author: STINNER Victor (vstinner) * (Python committer) | Date: 2019年01月17日 10:05 | |
Oops, I posted the following comment on the wrong issue... I wanted to post the following comment on this issue! I'm sorrry, I read the issue too quickly and misunderstood it. I guess that it's a duplicate of bpo-23428: "Use the monotonic clock for thread conditions on POSIX platforms". This issue is blocked the libc... |
|||
| msg333843 - (view) | Author: STINNER Victor (vstinner) * (Python committer) | Date: 2019年01月17日 10:06 | |
> looks like duplicate of bugs.python.org/issue23428 Yes. I close this issue as a duplicate of bpo-23428. Let's discuss the bug there! |
|||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022年04月11日 14:59:10 | admin | set | github: 79928 |
| 2021年10月01日 08:49:34 | vstinner | set | superseder: Use the monotonic clock for thread conditions on POSIX platforms -> threading.Condition.wait(timeout) should use a monotonic clock: use pthread_condattr_setclock(CLOCK_MONOTONIC) |
| 2019年01月17日 10:06:55 | vstinner | set | status: open -> closed superseder: Use the monotonic clock for thread conditions on POSIX platforms messages: + msg333843 stage: resolved |
| 2019年01月17日 10:05:51 | vstinner | set | messages: + msg333842 |
| 2019年01月17日 01:33:39 | ido k | set | resolution: duplicate messages: + msg333811 |
| 2019年01月16日 22:15:33 | pablogsal | set | nosy:
+ pablogsal messages: + msg333796 |
| 2019年01月15日 18:03:52 | ido k | set | messages: + msg333720 |
| 2019年01月15日 17:57:17 | vstinner | set | nosy:
+ vstinner messages: + msg333719 |
| 2019年01月15日 17:54:33 | ido k | create | |