Bug 33898: Alternative approach with receive frame timeout

See bug 33898 comment6.

Test plan:
Based on comment12: Stage MARC import and manage. Look at the same
time to the results of ps aux|grep Z. Verify that the lines with
[background_jobs] <defunct> disappear within 10 seconds.

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Victor Grousset/tuxayo <victor@tuxayo.net>
Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
This commit is contained in:
Marcel de Rooy 2024-03-08 07:37:19 +00:00 committed by Katrin Fischer
parent 4e166e07c1
commit bc42006019
Signed by: kfischer
GPG key ID: 0EF6E2C03357A834

View file

@ -73,6 +73,7 @@ my ( $help, @queues );
my $max_processes = $ENV{MAX_PROCESSES}; my $max_processes = $ENV{MAX_PROCESSES};
$max_processes ||= C4::Context->config('background_jobs_worker')->{max_processes} if C4::Context->config('background_jobs_worker'); $max_processes ||= C4::Context->config('background_jobs_worker')->{max_processes} if C4::Context->config('background_jobs_worker');
$max_processes ||= 1; $max_processes ||= 1;
my $mq_timeout = $ENV{MQ_TIMEOUT} // 10;
my $not_found_retries = {}; my $not_found_retries = {};
my $max_retries = $ENV{MAX_RETRIES} || 10; my $max_retries = $ENV{MAX_RETRIES} || 10;
@ -114,9 +115,10 @@ if ( $conn ) {
} }
while (1) { while (1) {
if ( $conn ) { if ( $conn ) {
my $frame = $conn->receive_frame; my $frame = $conn->receive_frame( { timeout => $mq_timeout } );
if ( !defined $frame ) { if ( !defined $frame ) {
# maybe log connection problems # timeout or connection issue?
$pm->reap_finished_children;
next; # will reconnect automatically next; # will reconnect automatically
} }