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
commitce041875b331c6cd4d308e7da550f5aca265c53e (patch)
tree3b62358a96f48201e00a2f5e1f4340928cf0ee23 /lib/custodian
parent017830edfabf028d60143b52f80971ceaaa41c1f (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