Skip to content

Commit

Permalink
Fix Timeoutless Job (#19266)
Browse files Browse the repository at this point in the history
  • Loading branch information
dbpolito authored and taylorotwell committed May 20, 2017
1 parent 7dbe8fd commit 650f74c
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/Illuminate/Queue/Worker.php
Original file line number Diff line number Diff line change
Expand Up @@ -131,15 +131,17 @@ public function daemon($connectionName, $queue, WorkerOptions $options)
*/
protected function registerTimeoutHandler($job, WorkerOptions $options)
{
if ($options->timeout > 0 && $this->supportsAsyncSignals()) {
$timeout = $this->timeoutForJob($job, $options);

if ($timeout > 0 && $this->supportsAsyncSignals()) {
// We will register a signal handler for the alarm signal so that we can kill this
// process if it is running too long because it has frozen. This uses the async
// signals supported in recent versions of PHP to accomplish it conveniently.
pcntl_signal(SIGALRM, function () {
$this->kill(1);
});

pcntl_alarm($this->timeoutForJob($job, $options) + $options->sleep);
pcntl_alarm($timeout + $options->sleep);
}
}

Expand Down

0 comments on commit 650f74c

Please sign in to comment.