Implemented --delay.

This commit is contained in:
Ole Tange 2012-11-26 22:57:07 +01:00
parent d47e1306ec
commit bc0f7701ec
5 changed files with 19 additions and 3 deletions

View file

@ -498,6 +498,7 @@ sub options_hash {
"basenameextensionreplace|bner=s" => \$opt::basenameextensionreplace,
"seqreplace=s" => \$opt::seqreplace,
"jobs|j=s" => \$opt::P,
"delay=f" => \$opt::delay,
"load=s" => \$opt::load,
"noswap" => \$opt::noswap,
"max-line-length-allowed" => \$opt::max_line_length_allowed,
@ -613,7 +614,7 @@ sub get_options_from_array {
sub parse_options {
# Returns: N/A
# Defaults:
$Global::version = 20121126;
$Global::version = 20121127;
$Global::progname = 'parallel';
$Global::infinity = 2**31;
$Global::debug = 0;
@ -3906,6 +3907,9 @@ sub start {
$job->set_timeout($opt::timeout);
$Global::timeoutq->insert($job);
}
if($opt::delay) {
::usleep($opt::delay*1000);
}
return $job;
} else {
# No more processes

View file

@ -426,6 +426,13 @@ occurs as a line of input, the rest of the input is ignored. If
neither B<-E> nor B<-e> is used, no end of file string is used.
=item B<--delay> I<secs> (alpha testing)
Delay starting next job I<secs> seconds. GNU B<parallel> will pause
I<secs> seconds after starting each job. I<secs> can be less than 1
seconds.
=item B<--dry-run>
Print the job to run on stdout (standard output), but do not run the

View file

@ -1086,7 +1086,7 @@ will generate the files:
and
@verbatim
parallel --results foo/bar echo {1} {2} ::: 1 2 ::: 3 4
parallel --results foo/bar echo {1} {2} ::: I II ::: III IIII
@end verbatim
will generate the files:

View file

@ -5,6 +5,9 @@ SERVER2=parallel-server2
# -L1 will join lines ending in ' '
cat <<'EOF' | sed -e s/\$SERVER1/$SERVER1/\;s/\$SERVER2/$SERVER2/ | parallel -j10 -k -L1
echo "### Test --delay"
seq 9 | /usr/bin/time -f %e parallel -j3 --delay 0.3 true {} 2>&1 | perl -pe 's/.[0-9]+$//'
echo '### Test -k 5';
sleep 5
@ -35,6 +38,6 @@ seq 1 10 | parallel -j 2 echo | sort
seq 1 10 | parallel -j 3 echo | sort
echo "bug #37694: Empty string argument skipped when using --quote"
parallel -q --nonall perl -le 'print scalar @ARGV' 'a' 'b' ''
parallel -q --nonall perl -le 'print scalar @ARGV' 'a' 'b' ''
EOF

View file

@ -1,3 +1,5 @@
### Test --delay
3
### Test -k 5
### Test -k 3
### Test -k 4