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.

classification
Title: Don't block on Queue get/put when time is moved back
Type: Stage:
Components: Library (Lib) Versions:
process
Status: closed Resolution: rejected
Dependencies: Superseder:
Assigned To: Nosy List: josiahcarlson, loewis, rhettinger, xiaowen
Priority: low Keywords: patch

Created on 2007-03-29 12:32 by xiaowen, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
time.patch xiaowen, 2007-03-29 12:32
Messages (6)
msg52329 - (view) Author: xiaowen (xiaowen) Date: 2007-03-29 12:32
When Queue get and put methods are called with a timeout, they effectively store the end time and might block until that end time is reached.  This breaks if the system time is moved back.  The attached patch breaks out of the wait if it detects the time has been moved back.
msg52330 - (view) Author: Josiah Carlson (josiahcarlson) * (Python triager) Date: 2007-04-09 20:36
I am unsure if this is a sufficient or correct patch, but the functionality is desirable.
msg52331 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2007-04-09 20:51
When a system moves time backwards, it breaks a host of invariants, not just the one in the queue module.  I would not want some variant of this code used everywhere time differences are computed.  Another thought is that the use case is somewhat exceptional and that the solution (readjusting endtime) isn't necessarily the right thing to do.
msg52332 - (view) Author: Josiah Carlson (josiahcarlson) * (Python triager) Date: 2007-04-09 21:21
I agree that it would be better to fix this everywhere we can.  But unless we start replacing the generic versions of everything that uses a timeout for platform-specific versions (that have guarantees regarding specified timeouts and notifications), about all we can really do is to patch each item as we go along.  I suppose a good first step would be to write a generic "wait for" function that would sit in threading, _Condition.wait() is a good start.  From there, one could write platform variants (Windows could use WaitForSingleObject, etc.) that don't change the end time, calling them on a platform if they exist.
msg52333 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2007-04-11 17:34
I was recommending against "fixing" this everywhere.  See related comments on pathc #1607149: Condition.wait timeout fails on clock change.

Recommend closing this patch.  The problem is not the responsibility of every client accessing time() or sleep().  The clients do not have enough information to reliably detect changes and to know how much the time changed.  Even if those are known, it is not clear that adjusting the timeout is the always right thing to do.

Also, this "problem" is somewhat obscure.  Lowering the priority to 1 and recommending that the patch (and all like it) be rejected.
msg52334 - (view) Author: Martin v. Löwis (loewis) * (Python committer) Date: 2007-04-15 07:28
Rejecting this patch for the same reason #1607149 was rejected.
History
Date User Action Args
2022-04-11 14:56:23adminsetgithub: 44783
2007-03-29 12:32:29xiaowencreate