You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The code snippet mentioned below will wait indefinitely until an element becomes available in the queue, while according to the documentation it should immediately raise a TimeoutError when the queue is empty.
from datetime import timedelta
from tornado import queues
q = queues.Queue()
q.get(timeout=timedelta(seconds=0))
This issue happens because timedelta(seconds=0) evaluates to a False value in a conditional expression. As such, the queues._set_timeout() method doesn't set the timeout when timeout=timedelta(seconds=0).
The text was updated successfully, but these errors were encountered:
Yes, that if timeout should be if timeout is not None (the same bug occurs with a float value of zero).
We also have a get_nowait() method which is a little more efficient, although it's not a drop-in replacement if you have to mix zero and non-zero timeouts (get_nowait() is a normal function and not a coroutine, so you have to call it without await).
The code snippet mentioned below will wait indefinitely until an element becomes available in the queue, while according to the documentation it should immediately raise a TimeoutError when the queue is empty.
This issue happens because
timedelta(seconds=0)
evaluates to a False value in a conditional expression. As such, the queues._set_timeout() method doesn't set the timeout whentimeout=timedelta(seconds=0)
.The text was updated successfully, but these errors were encountered: