diff options
author | Dan Fandrich <danf@mageia.org> | 2024-03-21 21:00:12 -0700 |
---|---|---|
committer | Dan Fandrich <danf@mageia.org> | 2024-03-21 21:00:12 -0700 |
commit | 82bfec6e44209b4e1bce115e4adca62d0fffb279 (patch) | |
tree | bb840e9be8ae0b2530a7074235c5d4d9bcb26757 /lib/MGA | |
parent | b9846fe26e87285ceab8ae5cd9c212325bd15f51 (diff) | |
download | mgaadvisories-82bfec6e44209b4e1bce115e4adca62d0fffb279.tar mgaadvisories-82bfec6e44209b4e1bce115e4adca62d0fffb279.tar.gz mgaadvisories-82bfec6e44209b4e1bce115e4adca62d0fffb279.tar.bz2 mgaadvisories-82bfec6e44209b4e1bce115e4adca62d0fffb279.tar.xz mgaadvisories-82bfec6e44209b4e1bce115e4adca62d0fffb279.zip |
Exit if any of the parallel processes return an error
Diffstat (limited to 'lib/MGA')
-rw-r--r-- | lib/MGA/Advisories.pm | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/lib/MGA/Advisories.pm b/lib/MGA/Advisories.pm index dbb7408..4663eb6 100644 --- a/lib/MGA/Advisories.pm +++ b/lib/MGA/Advisories.pm @@ -621,6 +621,14 @@ sub process_template { # Max 10 processes for processing templates my $pm = Parallel::ForkManager->new(10); +$pm->run_on_finish(\¶llel_finish); +my $parallelerror = 0; + +# Store error flag from forked process +sub parallel_finish { + my ($pid, $exit_code, $ident) = @_; + $parallelerror |= $exit_code; +} # Run process_template in its own process. The process creation overhead is # high, so this only makes sense for templates that interate over all or most @@ -633,9 +641,10 @@ sub parallel_process_template { } } -# Wait for all processes to finish +# Wait for all processes to finish & die if any returned an error sub parallel_complete { $pm->wait_all_children; + die "Error writing output" if $parallelerror; } sub output_pages { |