-
-
Notifications
You must be signed in to change notification settings - Fork 32k
Queue get timout parameter does not use a monotonic timer #104509
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
@rhettinger (as a |
do you have a reproducible code? Line 7 in 0bb61dd
As the issue template suggests you should share the reproducible code and the execution environment as well |
I am using Python 3.8.6 on Linux. There is a variable in the attached script called Make_It_Fail that is set to True. You can set it to False to see how the script works without date/time changes then set it to True to see how queue.get does not return after 10 seconds has elapsed. |
This seems to have been resolved in Python 3.9, 3.10. See here: #85876 |
I tried my queue_timeout.test.py script on Python 3.11 and it still does not timeout after 10 seconds. The queue.get() function blocks and seems to still be effected by changes to the system time on Linux. |
I can't reproduce the bug on current HEAD (v3.15-alpha), but then I can't reproduce it on v3.11.0 either. In both cases it produces the correct, expected output:
As @Agent-Hellboy says, the queue code itself uses a monotonic clock, and after #28662 so does the underlying lock the condition variable waits on. @fdirosa4188 please re-test and close if confirmed. |
It is clear looking at the source code that the Queue class uses time() and other non-monotonic timing sources. So if a queue get function is called with a timeout value and the system time is changed during that get it could end up waiting in the get for potentially days. The easiest way to reproduce is to set the timeout in the get to 5 minutes and which it is waiting on the queue to get an entry set the system clock back a few years. You will notice it will not exit the get.
The text was updated successfully, but these errors were encountered: