Skip to content

Commit

Permalink
Add catch exception when connect and get job
Browse files Browse the repository at this point in the history
  • Loading branch information
卢杨 committed May 25, 2016
1 parent e8cb617 commit e53d363
Showing 1 changed file with 16 additions and 9 deletions.
25 changes: 16 additions & 9 deletions src/Illuminate/Queue/Worker.php
Original file line number Diff line number Diff line change
Expand Up @@ -143,17 +143,24 @@ protected function daemonShouldRun()
*/
public function pop($connectionName, $queue = null, $delay = 0, $sleep = 3, $maxTries = 0)
{
$connection = $this->manager->connection($connectionName);
try {
$connection = $this->manager->connection($connectionName);

$job = $this->getNextJob($connection, $queue);
$job = $this->getNextJob($connection, $queue);

// If we're able to pull a job off of the stack, we will process it and
// then immediately return back out. If there is no job on the queue
// we will "sleep" the worker for the specified number of seconds.
if (! is_null($job)) {
return $this->process(
$this->manager->getName($connectionName), $job, $maxTries, $delay
);
// If we're able to pull a job off of the stack, we will process it and
// then immediately return back out. If there is no job on the queue
// we will "sleep" the worker for the specified number of seconds.
if (! is_null($job)) {
return $this->process(
$this->manager->getName($connectionName), $job, $maxTries, $delay
);
}
} catch (Exception $e) {
if ($this->exceptions) {
$this->exceptions->report($e);
}
$this->stop();
}

$this->sleep($sleep);
Expand Down

0 comments on commit e53d363

Please sign in to comment.