UPDATE: this question is based on the erroneous mental behavior model of Queue.get (), which was triggered by some slightly ambiguous documentation, but mainly because of the erroneous, manual implementation of timedelta.total_seconds() . I found this error while trying to prove that the original answers are incorrect. Now that timedelta.total_seconds() provided by Python (since version 2.7), I will use it.
Sorry for the confusion.
This is not "Why is my code not starting?" question, but "What is the motivation for this design decision?"
Starting in 2.3, the Python queue module contains a Queue class with a get method that takes a timeout parameter. Here is the section from the manual:
Queue.get([block[, timeout]])
Remove and return the item from the queue. If the optional argument args is true and timeout is None (the default), block, if necessary, until the item is available. If the timeout is a positive number, it blocks no more than a timeout of seconds and throws an Empty exception if no items were available during this time. [...]
(Emphasis mine)
Note that this may raise an Empty exception even if it does not reach a timeout. In fact, I see this behavior on Ubuntu (but not on Windows). This is a guarantee a little earlier, and I had minor consequences for my code - I can encode it, though.
Most lock timeouts take a minimum timeout, which makes sense in real-time operating systems, including Windows and Linux. There is no guarantee that the OS will switch the context to your process or thread at any given time.
However, this requires a maximum timeout. Can someone explain how this constructive solution can make sense?
source share