Prevent the use of indefinite timeouts.

Using them would really mess with the new expiring worker keys (they
would disappear, even though the workers aren't dead).
This commit is contained in:
Vincent Driessen 2013-02-15 08:50:27 +01:00
parent e0866cdc6c
commit d39badb4cc
1 changed files with 7 additions and 6 deletions

View File

@ -196,19 +196,20 @@ class Queue(object):
Until Redis receives a specific method for this, we'll have to wrap it
this way.
The timeout parameter is interpreted thus:
0 - no timeout (block forever)
None - non-blocking (return value or None immediately)
<integer> - maximum seconds to block
The timeout parameter is interpreted as follows:
None - non-blocking (return immediately)
> 0 - maximum number of seconds to block
"""
connection = resolve_connection(connection)
if timeout is not None:
if timeout is not None: # blocking variant
if timeout == 0:
raise ValueError('RQ does not support indefinite timeouts. Please pick a timeout value > 0.')
result = connection.blpop(queue_keys, timeout)
if result is None:
raise DequeueTimeout(timeout, queue_keys)
queue_key, job_id = result
return queue_key, job_id
else:
else: # non-blocking variant
for queue_key in queue_keys:
blob = connection.lpop(queue_key)
if blob is not None: