Skip to content

Commit c8316ee

Browse files
committed
Worker Fix Job With no Timeout
1 parent c46eee1 commit c8316ee

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

src/Illuminate/Queue/Worker.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -131,17 +131,20 @@ public function daemon($connectionName, $queue, WorkerOptions $options)
131131
*/
132132
protected function registerTimeoutHandler($job, WorkerOptions $options)
133133
{
134-
$timeout = $this->timeoutForJob($job, $options);
135134

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

144-
pcntl_alarm($timeout + $options->sleep);
143+
// We need to set this everytime, because if we have a job with
144+
// no timeout we need to clean the alarm of previous job.
145+
$timeout = $this->timeoutForJob($job, $options);
146+
147+
pcntl_alarm($timeout > 0 ? $timeout + $options->sleep : 0);
145148
}
146149
}
147150

0 commit comments

Comments
 (0)