summaryrefslogtreecommitdiff
path: root/lib/custodian
diff options
context:
space:
mode:
authorSteve Kemp <steve@steve.org.uk>2015-02-18 10:25:16 +0000
committerSteve Kemp <steve@steve.org.uk>2015-02-18 10:25:16 +0000
commit4e4fb3d971bcc53e7958ba8ad42ad8413766f9d7 (patch)
tree0eac932c38486f28fd3fe5c5b4df9f861aeeae86 /lib/custodian
parent9f07883ab93df9f6dc1b402ffaad084cfbfcfd74 (diff)
Prefer "while true" to "while 1"
Also only sleep between fetches if we couldn't find a job because the queue was empty.
Diffstat (limited to 'lib/custodian')
-rw-r--r--lib/custodian/queue.rb10
1 files changed, 7 insertions, 3 deletions
diff --git a/lib/custodian/queue.rb b/lib/custodian/queue.rb
index 1ef9c61..1bdbee2 100644
--- a/lib/custodian/queue.rb
+++ b/lib/custodian/queue.rb
@@ -94,12 +94,16 @@ end
def fetch(timeout = 1)
job = nil
- while( 1 )
+ while( true )
foo, job = @redis.blpop( "queue", :timeout => timeout )
- return job if ( job )
- sleep( timeout )
+ if ( job )
+ return job
+ else
+ sleep( timeout )
+ end
+
end
end