Skip to content

Commit 84439b4

Browse files
committed
sleep x seconds if no blocking queue was found
1 parent 968b7e6 commit 84439b4

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

lib/Resque/Worker.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,11 @@ public function reserve($blocking = false, $timeout = null)
262262
}
263263

264264
if($blocking === true) {
265+
if(empty($queues)){
266+
$this->logger->log(Psr\Log\LogLevel::INFO, 'No queue was found, sleeping for {interval}', array('interval' => $timeout));
267+
usleep($timeout * 1000000);
268+
return false;
269+
}
265270
$job = Resque_Job::reserveBlocking($queues, $timeout);
266271
if($job) {
267272
$this->logger->log(Psr\Log\LogLevel::INFO, 'Found job on {queue}', array('queue' => $job->queue));

0 commit comments

Comments
 (0)