From c65186c8df6fe4320562d9defcffa28ee1c1c50b Mon Sep 17 00:00:00 2001 From: Mohamed Said Date: Wed, 22 Jan 2020 11:38:14 +0200 Subject: [PATCH 1/2] reset timout handler after worker loop --- src/Illuminate/Queue/Worker.php | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/Illuminate/Queue/Worker.php b/src/Illuminate/Queue/Worker.php index 9c3de7676c09..f737c7688315 100644 --- a/src/Illuminate/Queue/Worker.php +++ b/src/Illuminate/Queue/Worker.php @@ -122,6 +122,7 @@ public function daemon($connectionName, $queue, WorkerOptions $options) $job = $this->getNextJob( $this->manager->connection($connectionName), $queue ); + sleep(5); if ($this->supportsAsyncSignals()) { $this->registerTimeoutHandler($job, $options); @@ -136,6 +137,8 @@ public function daemon($connectionName, $queue, WorkerOptions $options) $this->sleep($options->sleep); } + $this->resetTimeoutHandler(); + // Finally, we will check to see if we have exceeded our memory limits or if // the queue should restart based on other indications. If so, we'll stop // this worker and let whatever is "monitoring" it restart the process. @@ -170,6 +173,16 @@ protected function registerTimeoutHandler($job, WorkerOptions $options) ); } + /** + * Reset the worker timeout handler. + * + * @return void + */ + protected function resetTimeoutHandler() + { + pcntl_alarm(0); + } + /** * Get the appropriate timeout for the given job. * From 08a1805bedee736b55d0c7451379c72401be3ec6 Mon Sep 17 00:00:00 2001 From: Mohamed Said Date: Wed, 22 Jan 2020 11:39:10 +0200 Subject: [PATCH 2/2] clean --- src/Illuminate/Queue/Worker.php | 1 - 1 file changed, 1 deletion(-) diff --git a/src/Illuminate/Queue/Worker.php b/src/Illuminate/Queue/Worker.php index f737c7688315..65688c14a5a3 100644 --- a/src/Illuminate/Queue/Worker.php +++ b/src/Illuminate/Queue/Worker.php @@ -122,7 +122,6 @@ public function daemon($connectionName, $queue, WorkerOptions $options) $job = $this->getNextJob( $this->manager->connection($connectionName), $queue ); - sleep(5); if ($this->supportsAsyncSignals()) { $this->registerTimeoutHandler($job, $options);