php-resque icon indicating copy to clipboard operation
php-resque copied to clipboard

pcntl_signal_dispatch(); missing

Open spiritdead opened this issue 7 years ago • 5 comments

Careful with this, if you no have this function inside in the while of the worker whenyou generate the signal for shutdown, this never is fired, you have to call this function pcntl_signal_dispatch(); //affected in ubuntu 16.04 (tested)

should be

while (true) { if(function_exists('pcntl_signal_dispatch')) { pcntl_signal_dispatch(); } if ($this->shutdown) { break; }

spiritdead avatar Mar 25 '17 09:03 spiritdead

can you give some references to read and make a PR for this?

Hikariii avatar Apr 13 '17 06:04 Hikariii

@Hikariii in the method work in the workers for example this

public function work()
{
    if ($interval !== null) {
        $this->interval = $interval;
    }
    $this->updateProcLine('Starting');
    $this->startup();
    while (true) {
        if (function_exists('pcntl_signal_dispatch')) {
            pcntl_signal_dispatch();
        }
        if ($this->shutdown) {
            break;
        }

if you no call the dispatch, if you fire a signal this keep waiting until you fire the dispatch for run in php

spiritdead avatar Apr 13 '17 12:04 spiritdead

@spiritdead @Hikariii I was running older version of php-resque and upgrading to PHP7 and found things not working, and suspected I need to do pcntl_signal_dispatch() , but the issue was that I didn't have this change https://github.com/chrisboulton/php-resque/pull/296

agentile avatar May 05 '17 19:05 agentile

Note that PHP 7.x is not properly supported at this time, so YMMV.

danhunsaker avatar May 05 '17 20:05 danhunsaker

on PHP 7.1, the worker is getting stalled after performing the first job in the Queue. I have added more details here https://github.com/resquebundle/resque/issues/24

vamsiikrishna avatar Jul 27 '17 11:07 vamsiikrishna