3

According to the Laravel docs I should be able to specify a job specific timeout:

If the timeout is specified on the job, it will take precedence over any timeout specified on the command line [...]

So, when I run artisan queue:listen without the --timeout option and I define the timeout inside the job (like Laravel tells me to):

public $timeout = 600;

I expect the timeout of that specific job to be 600 seconds. Unfortunately, I still get a ProcessTimedOutException. A custom timeout only works when I run the queue with --timeout=600.

I'm using Laravel 6 with PHP 7.4. As recommended by Laravel I've also enabled the pcntl PHP extension. For the queue I use the database driver with the following config:

'database' => [
    'driver' => 'database',
    'table' => 'jobs',
    'queue' => 'default',
    'retry_after' => 90,
]
SomeCode
  • 179
  • 2
  • 15
  • What are the configuration settings for the queue in queue.php file? – Daniel Protopopov Jan 24 '20 at 10:23
  • 1
    What happen if you change `retry_after` to `610`? –  Jan 24 '20 at 11:32
  • The answer is in the official documentation of the Laravel for [queues](https://laravel.com/docs/master/queues#job-expirations-and-timeouts), right at the beginning of the link. --timeout for command line is there as well. – Daniel Protopopov Jan 24 '20 at 12:08
  • I want to set the timeout in the job class, not the command line. This should be possible according to the last few paragraphs of [this](https://laravel.com/docs/master/queues#max-job-attempts-and-timeout) section. Setting the timeout in the command line will set it for all jobs. – SomeCode Jan 24 '20 at 14:46

1 Answers1

3

I opened a bug report because I couldn't get this to work. However, it seems like the timeout specified inside the job class only takes precedence over the timeout specified in the command line when running the queue with queue:work.

I've tested this and can confirm that it works with queue:work. According to a commenter on my bug report it doesn't work with queue:listen because:

queue:listen runs several processes while queue:work is a single process. queue:listen sets a timeout for the process it runs so we don't leave ghost processes running on the machine in case the master process was killed for some reason.

SomeCode
  • 179
  • 2
  • 15