mirror of
https://git.savannah.gnu.org/git/parallel.git
synced 2024-11-22 22:17:54 +00:00
parallel: Use status() for status message instead of directly using STDERR.
This commit is contained in:
parent
163712f709
commit
b867e321e9
|
@ -242,6 +242,8 @@ New in this release:
|
||||||
|
|
||||||
* GNU Parallel was cited in: Distinguishing cause from effect using observational data: methods and benchmarks http://arxiv-web3.library.cornell.edu/pdf/1412.3773.pdf
|
* GNU Parallel was cited in: Distinguishing cause from effect using observational data: methods and benchmarks http://arxiv-web3.library.cornell.edu/pdf/1412.3773.pdf
|
||||||
|
|
||||||
|
* GNU Parallel was cited in: Bayesian Inference of Protein Structure from Chemical Shift Data https://peerj.com/preprints/692.pdf
|
||||||
|
|
||||||
* GNU Parallel: Open Source For You (OSFY) magazine, October 2013 edition http://www.shakthimaan.com/posts/2014/11/27/gnu-parallel/news.html
|
* GNU Parallel: Open Source For You (OSFY) magazine, October 2013 edition http://www.shakthimaan.com/posts/2014/11/27/gnu-parallel/news.html
|
||||||
|
|
||||||
* コマンドを並列に実行するGNU parallelがとても便利 http://bicycle1885.hatenablog.com/entry/2014/08/10/143612
|
* コマンドを並列に実行するGNU parallelがとても便利 http://bicycle1885.hatenablog.com/entry/2014/08/10/143612
|
||||||
|
|
53
src/parallel
53
src/parallel
|
@ -1568,6 +1568,8 @@ sub save_stdin_stdout_stderr {
|
||||||
}
|
}
|
||||||
open $Global::original_stderr, ">&", "STDERR" or
|
open $Global::original_stderr, ">&", "STDERR" or
|
||||||
::die_bug("Can't dup STDERR: $!");
|
::die_bug("Can't dup STDERR: $!");
|
||||||
|
open $Global::status_fd, ">&", "STDERR" or
|
||||||
|
::die_bug("Can't dup STDERR: $!");
|
||||||
open $Global::original_stdin, "<&", "STDIN" or
|
open $Global::original_stdin, "<&", "STDIN" or
|
||||||
::die_bug("Can't dup STDIN: $!");
|
::die_bug("Can't dup STDIN: $!");
|
||||||
}
|
}
|
||||||
|
@ -1881,7 +1883,7 @@ sub drain_job_queue {
|
||||||
# $Global::start_no_new_jobs
|
# $Global::start_no_new_jobs
|
||||||
# Returns: N/A
|
# Returns: N/A
|
||||||
if($opt::progress) {
|
if($opt::progress) {
|
||||||
print $Global::original_stderr init_progress();
|
::status(init_progress());
|
||||||
}
|
}
|
||||||
my $last_header="";
|
my $last_header="";
|
||||||
my $sleep = 0.2;
|
my $sleep = 0.2;
|
||||||
|
@ -1898,11 +1900,10 @@ sub drain_job_queue {
|
||||||
if($opt::progress) {
|
if($opt::progress) {
|
||||||
my %progress = progress();
|
my %progress = progress();
|
||||||
if($last_header ne $progress{'header'}) {
|
if($last_header ne $progress{'header'}) {
|
||||||
print $Global::original_stderr "\n", $progress{'header'}, "\n";
|
::status("\n", $progress{'header'}, "\n");
|
||||||
$last_header = $progress{'header'};
|
$last_header = $progress{'header'};
|
||||||
}
|
}
|
||||||
print $Global::original_stderr "\r",$progress{'status'};
|
::status("\r",$progress{'status'});
|
||||||
flush $Global::original_stderr;
|
|
||||||
}
|
}
|
||||||
if($Global::total_running < $Global::max_jobs_running
|
if($Global::total_running < $Global::max_jobs_running
|
||||||
and not $Global::JobQueue->empty()) {
|
and not $Global::JobQueue->empty()) {
|
||||||
|
@ -1936,8 +1937,7 @@ sub drain_job_queue {
|
||||||
not $Global::start_no_new_jobs and not $Global::JobQueue->empty());
|
not $Global::start_no_new_jobs and not $Global::JobQueue->empty());
|
||||||
if($opt::progress) {
|
if($opt::progress) {
|
||||||
my %progress = progress();
|
my %progress = progress();
|
||||||
print $Global::original_stderr "\r", $progress{'status'}, "\n";
|
::status("\r", $progress{'status'}, "\n");
|
||||||
flush $Global::original_stderr;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1945,11 +1945,10 @@ sub toggle_progress {
|
||||||
# Turn on/off progress view
|
# Turn on/off progress view
|
||||||
# Uses:
|
# Uses:
|
||||||
# $opt::progress
|
# $opt::progress
|
||||||
# $Global::original_stderr
|
|
||||||
# Returns: N/A
|
# Returns: N/A
|
||||||
$opt::progress = not $opt::progress;
|
$opt::progress = not $opt::progress;
|
||||||
if($opt::progress) {
|
if($opt::progress) {
|
||||||
print $Global::original_stderr init_progress();
|
::status(init_progress());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2761,14 +2760,14 @@ sub save_original_signal_handler {
|
||||||
sub list_running_jobs {
|
sub list_running_jobs {
|
||||||
# Returns: N/A
|
# Returns: N/A
|
||||||
for my $v (values %Global::running) {
|
for my $v (values %Global::running) {
|
||||||
print $Global::original_stderr "$Global::progname: ",$v->replaced(),"\n";
|
::status("$Global::progname: ",$v->replaced(),"\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
sub start_no_new_jobs {
|
sub start_no_new_jobs {
|
||||||
# Returns: N/A
|
# Returns: N/A
|
||||||
$SIG{TERM} = $Global::original_sig{TERM};
|
$SIG{TERM} = $Global::original_sig{TERM};
|
||||||
print $Global::original_stderr
|
::status
|
||||||
("$Global::progname: SIGTERM received. No new jobs will be started.\n",
|
("$Global::progname: SIGTERM received. No new jobs will be started.\n",
|
||||||
"$Global::progname: Waiting for these ", scalar(keys %Global::running),
|
"$Global::progname: Waiting for these ", scalar(keys %Global::running),
|
||||||
" jobs to finish. Send SIGTERM again to stop now.\n");
|
" jobs to finish. Send SIGTERM again to stop now.\n");
|
||||||
|
@ -2848,7 +2847,7 @@ sub process_failed_job {
|
||||||
$Global::total_failed / $Global::total_started > $opt::halt_on_error)) {
|
$Global::total_failed / $Global::total_started > $opt::halt_on_error)) {
|
||||||
# If halt on error == 1 or --halt 10%
|
# If halt on error == 1 or --halt 10%
|
||||||
# we should gracefully exit
|
# we should gracefully exit
|
||||||
print $Global::original_stderr
|
::status
|
||||||
("$Global::progname: Starting no more jobs. ",
|
("$Global::progname: Starting no more jobs. ",
|
||||||
"Waiting for ", scalar(keys %Global::running),
|
"Waiting for ", scalar(keys %Global::running),
|
||||||
" jobs to finish. This job failed:\n",
|
" jobs to finish. This job failed:\n",
|
||||||
|
@ -2857,7 +2856,7 @@ sub process_failed_job {
|
||||||
$Global::halt_on_error_exitstatus = $job->exitstatus();
|
$Global::halt_on_error_exitstatus = $job->exitstatus();
|
||||||
} elsif($opt::halt_on_error == 2) {
|
} elsif($opt::halt_on_error == 2) {
|
||||||
# If halt on error == 2 we should exit immediately
|
# If halt on error == 2 we should exit immediately
|
||||||
print $Global::original_stderr
|
::status
|
||||||
("$Global::progname: This job failed:\n",
|
("$Global::progname: This job failed:\n",
|
||||||
$job->replaced(),"\n");
|
$job->replaced(),"\n");
|
||||||
exit ($job->exitstatus());
|
exit ($job->exitstatus());
|
||||||
|
@ -2973,7 +2972,7 @@ sub citation_notice {
|
||||||
-e $ENV{'HOME'}."/.parallel/will-cite") {
|
-e $ENV{'HOME'}."/.parallel/will-cite") {
|
||||||
# skip
|
# skip
|
||||||
} else {
|
} else {
|
||||||
print $Global::original_stderr
|
::status
|
||||||
("Academic tradition requires you to cite works you base your article on.\n",
|
("Academic tradition requires you to cite works you base your article on.\n",
|
||||||
"When using programs that use GNU Parallel to process data for publication please cite:\n",
|
"When using programs that use GNU Parallel to process data for publication please cite:\n",
|
||||||
"\n",
|
"\n",
|
||||||
|
@ -2985,27 +2984,30 @@ sub citation_notice {
|
||||||
"\n",
|
"\n",
|
||||||
"To silence this citation notice run 'parallel --bibtex' once or use '--no-notice'.\n\n",
|
"To silence this citation notice run 'parallel --bibtex' once or use '--no-notice'.\n\n",
|
||||||
);
|
);
|
||||||
flush $Global::original_stderr;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sub status {
|
||||||
|
my @w = @_;
|
||||||
|
my $fh = $Global::status_fd || *STDERR;
|
||||||
|
print $fh @w;
|
||||||
|
flush $fh;
|
||||||
|
}
|
||||||
|
|
||||||
sub warning {
|
sub warning {
|
||||||
my @w = @_;
|
my @w = @_;
|
||||||
my $fh = $Global::original_stderr || *STDERR;
|
my $fh = $Global::status_fd || *STDERR;
|
||||||
my $prog = $Global::progname || "parallel";
|
my $prog = $Global::progname || "parallel";
|
||||||
print $fh $prog, ": Warning: ", @w;
|
print $fh $prog, ": Warning: ", @w;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
sub error {
|
sub error {
|
||||||
my @w = @_;
|
my @w = @_;
|
||||||
my $fh = $Global::original_stderr || *STDERR;
|
my $fh = $Global::status_fd || *STDERR;
|
||||||
my $prog = $Global::progname || "parallel";
|
my $prog = $Global::progname || "parallel";
|
||||||
print $fh $prog, ": Error: ", @w;
|
print $fh $prog, ": Error: ", @w;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
sub die_bug {
|
sub die_bug {
|
||||||
my $bugid = shift;
|
my $bugid = shift;
|
||||||
print STDERR
|
print STDERR
|
||||||
|
@ -3446,7 +3448,7 @@ sub my_dump {
|
||||||
if ($@) {
|
if ($@) {
|
||||||
my $err = "Neither Data::Dump nor Data::Dumper is installed\n".
|
my $err = "Neither Data::Dump nor Data::Dumper is installed\n".
|
||||||
"Not dumping output\n";
|
"Not dumping output\n";
|
||||||
print $Global::original_stderr $err;
|
::status($err);
|
||||||
return $err;
|
return $err;
|
||||||
} else {
|
} else {
|
||||||
return Dumper(@dump_this);
|
return Dumper(@dump_this);
|
||||||
|
@ -3939,11 +3941,11 @@ sub compute_max_loadavg {
|
||||||
close $in_fh;
|
close $in_fh;
|
||||||
$load = $self->compute_max_loadavg($opt_load_file);
|
$load = $self->compute_max_loadavg($opt_load_file);
|
||||||
} else {
|
} else {
|
||||||
print $Global::original_stderr "Cannot open $loadspec\n";
|
::error("Cannot open $loadspec\n");
|
||||||
::wait_and_exit(255);
|
::wait_and_exit(255);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
print $Global::original_stderr "Parsing of --load failed\n";
|
::error("Parsing of --load failed\n");
|
||||||
::die_usage();
|
::die_usage();
|
||||||
}
|
}
|
||||||
if($load < 0.01) {
|
if($load < 0.01) {
|
||||||
|
@ -4144,9 +4146,8 @@ sub compute_number_of_processes {
|
||||||
# It took more than 0.01 second to fork a processes on avg.
|
# It took more than 0.01 second to fork a processes on avg.
|
||||||
# Give the user a warning. He can press Ctrl-C if this
|
# Give the user a warning. He can press Ctrl-C if this
|
||||||
# sucks.
|
# sucks.
|
||||||
print $Global::original_stderr
|
::warning("Starting $system_limit processes took > $forktime sec.\n",
|
||||||
("parallel: Warning: Starting $system_limit processes took > $forktime sec.\n",
|
"Consider adjusting -j. Press CTRL-C to stop.\n");
|
||||||
"Consider adjusting -j. Press CTRL-C to stop.\n");
|
|
||||||
$slow_spawining_warning_printed = 1;
|
$slow_spawining_warning_printed = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -6059,7 +6060,7 @@ sub start {
|
||||||
sub interactive_start {
|
sub interactive_start {
|
||||||
my $command = shift;
|
my $command = shift;
|
||||||
if($Global::interactive) {
|
if($Global::interactive) {
|
||||||
print $Global::original_stderr "$command ?...";
|
::status("$command ?...");
|
||||||
open(my $tty_fh, "<", "/dev/tty") || ::die_bug("interactive-tty");
|
open(my $tty_fh, "<", "/dev/tty") || ::die_bug("interactive-tty");
|
||||||
my $answer = <$tty_fh>;
|
my $answer = <$tty_fh>;
|
||||||
close $tty_fh;
|
close $tty_fh;
|
||||||
|
@ -6110,7 +6111,7 @@ sub tmux_wrap {
|
||||||
if($Global::total_running == 0) {
|
if($Global::total_running == 0) {
|
||||||
$tmux = "tmux new-session -s p$$ -d -n ".
|
$tmux = "tmux new-session -s p$$ -d -n ".
|
||||||
::shell_quote_scalar($title);
|
::shell_quote_scalar($title);
|
||||||
print $Global::original_stderr "See output with: tmux attach -t p$$\n";
|
::status("See output with: tmux attach -t p$$\n");
|
||||||
} else {
|
} else {
|
||||||
$tmux = "tmux new-window -t p$$ -n ".::shell_quote_scalar($title);
|
$tmux = "tmux new-window -t p$$ -n ".::shell_quote_scalar($title);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue