diff --git a/doc/release_new_version b/doc/release_new_version index 67213906..2fa86771 100644 --- a/doc/release_new_version +++ b/doc/release_new_version @@ -266,6 +266,8 @@ for Big Data Applications https://ieeexplore.ieee.org/stamp/stamp.jsp?tp=&arnumb * FaceCrop uses GNU Parallel: https://github.com/EderSantana/FaceCrop +* Parallel Processing with Catmandu https://librecatproject.wordpress.com/2016/04/20/parallel-processing-with-catmandu/ + * GNU parallel 應用範例 http://staypython.blogspot.dk/2016/04/gnu-parallel.html * Bug fixes and man page updates. diff --git a/src/parallel b/src/parallel index 9214924b..912954af 100755 --- a/src/parallel +++ b/src/parallel @@ -1183,7 +1183,7 @@ sub check_invalid_option_combinations { sub init_globals { # Defaults: - $Global::version = 20160414; + $Global::version = 20160420; $Global::progname = 'parallel'; $Global::infinity = 2**31; $Global::debug = 0; @@ -4170,8 +4170,14 @@ sub reap_usleep { delete $SIG{CHLD}; exit_if_disk_full(); if($opt::linebuffer) { - for my $job (values %Global::running) { - $job->print(); + if($opt::keeporder) { + for my $job (values %Global::running) { + $job->print_earlier_jobs(); + } + } else { + for my $job (values %Global::running) { + $job->print(); + } } } # Sleep exponentially longer (1.1^n) if a job did not finish, @@ -7782,24 +7788,28 @@ sub should_be_retried { } { - my (%print_later,$job_end_sequence); + my (%print_later,$job_seq_to_print); sub print_earlier_jobs { # Print jobs whose output is postponed due to --keep-order # Returns: N/A my $job = shift; $print_later{$job->seq()} = $job; - $job_end_sequence ||= 1; - ::debug("run", "Looking for: $job_end_sequence ", - "Current: ", $job->seq(), "\n"); - for(my $j = $print_later{$job_end_sequence}; - $j or vec($Global::job_already_run,$job_end_sequence,1); - $job_end_sequence++, - $j = $print_later{$job_end_sequence}) { - ::debug("run", "Found job end $job_end_sequence"); - if($j) { - $j->print(); - delete $print_later{$job_end_sequence}; + $job_seq_to_print ||= 1; + ::debug("run", "Looking for: $job_seq_to_print ", + "This: ", $job->seq(), "\n"); + for(;vec($Global::job_already_run,$job_seq_to_print,1); + $job_seq_to_print++) {} + while(my $j = $print_later{$job_seq_to_print}) { + $j->print(); + if($j->endtime()) { + # Job finished - look at the next + delete $print_later{$job_seq_to_print}; + $job_seq_to_print++; + next; + } else { + # Job not finished yet - look at it again next round + last; } } } diff --git a/testsuite/tests-to-run/parallel-local-10s.sh b/testsuite/tests-to-run/parallel-local-10s.sh index b2b08901..a30753e1 100644 --- a/testsuite/tests-to-run/parallel-local-10s.sh +++ b/testsuite/tests-to-run/parallel-local-10s.sh @@ -92,5 +92,9 @@ echo '### test memfree' echo '**' +echo '### bug #47750: -k --line-buffer should give current job up to now' + + parallel --line-buffer --tag -k 'seq {} | pv -qL 10' ::: {10..20} + parallel --line-buffer -k 'echo stdout top;sleep 1;echo stderr in the middle >&2; sleep 1;echo stdout' ::: end 2>&1 EOF diff --git a/testsuite/wanted-results/parallel-local-10s b/testsuite/wanted-results/parallel-local-10s index 538c3657..d7d6cd8e 100644 --- a/testsuite/wanted-results/parallel-local-10s +++ b/testsuite/wanted-results/parallel-local-10s @@ -676,3 +676,175 @@ parallel: SIGTERM received. No new jobs will be started. parallel: Waiting for these 0 jobs to finish. Send SIGTERM again to stop now. echo '**' ** +echo '### bug #47750: -k --line-buffer should give current job up to now' +### bug #47750: -k --line-buffer should give current job up to now + parallel --line-buffer --tag -k 'seq {} | pv -qL 10' ::: {10..20} +10 1 +10 2 +10 3 +10 4 +10 5 +10 6 +10 7 +10 8 +10 9 +10 10 +11 1 +11 2 +11 3 +11 4 +11 5 +11 6 +11 7 +11 8 +11 9 +11 10 +11 11 +12 1 +12 2 +12 3 +12 4 +12 5 +12 6 +12 7 +12 8 +12 9 +12 10 +12 11 +12 12 +13 1 +13 2 +13 3 +13 4 +13 5 +13 6 +13 7 +13 8 +13 9 +13 10 +13 11 +13 12 +13 13 +14 1 +14 2 +14 3 +14 4 +14 5 +14 6 +14 7 +14 8 +14 9 +14 10 +14 11 +14 12 +14 13 +14 14 +15 1 +15 2 +15 3 +15 4 +15 5 +15 6 +15 7 +15 8 +15 9 +15 10 +15 11 +15 12 +15 13 +15 14 +15 15 +16 1 +16 2 +16 3 +16 4 +16 5 +16 6 +16 7 +16 8 +16 9 +16 10 +16 11 +16 12 +16 13 +16 14 +16 15 +16 16 +17 1 +17 2 +17 3 +17 4 +17 5 +17 6 +17 7 +17 8 +17 9 +17 10 +17 11 +17 12 +17 13 +17 14 +17 15 +17 16 +17 17 +18 1 +18 2 +18 3 +18 4 +18 5 +18 6 +18 7 +18 8 +18 9 +18 10 +18 11 +18 12 +18 13 +18 14 +18 15 +18 16 +18 17 +18 18 +19 1 +19 2 +19 3 +19 4 +19 5 +19 6 +19 7 +19 8 +19 9 +19 10 +19 11 +19 12 +19 13 +19 14 +19 15 +19 16 +19 17 +19 18 +19 19 +20 1 +20 2 +20 3 +20 4 +20 5 +20 6 +20 7 +20 8 +20 9 +20 10 +20 11 +20 12 +20 13 +20 14 +20 15 +20 16 +20 17 +20 18 +20 19 +20 20 + parallel --line-buffer -k 'echo stdout top;sleep 1;echo stderr in the middle >&2; sleep 1;echo stdout' ::: end 2>&1 +stdout top +stderr in the middle +stdout end