From d39badb4cc203cf6e20432366a8c1471c284d9ab Mon Sep 17 00:00:00 2001 From: Vincent Driessen Date: Fri, 15 Feb 2013 08:50:27 +0100 Subject: [PATCH] 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). --- rq/queue.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/rq/queue.py b/rq/queue.py index 3233770b..f3c47c25 100644 --- a/rq/queue.py +++ b/rq/queue.py @@ -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) - - 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: