Skip to content

Commit

Permalink
Don't sleep if there are more jobs to run.
Browse files Browse the repository at this point in the history
Modify `bric_queued` so that it only sleeps for `--delay` seconds if it
executed no jobs. Otherwise it immediately runs again, on the assumption that
there will be more jobs that should be executed sooner rather than later. The
upshot is that files will now be distributed much sooner after publishling.
  • Loading branch information
theory committed Jul 7, 2010
1 parent 8f802b0 commit 9b73869
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
5 changes: 5 additions & 0 deletions bin/bric_queued
Expand Up @@ -229,6 +229,7 @@ sub run_as_daemon {
my $pkg = fork_to_dist();
login();
while (1) {
my $has_jobs = 0;
for my $job ($pkg->list({
sched_time => [undef, strfdate()],
comp_time => undef,
Expand All @@ -237,6 +238,7 @@ sub run_as_daemon {
Limit => $Chunks,
})) {
logit('Executing ' . $job->get_name . "\n") if $Verbose;
$has_jobs = 1;
eval {
$job->execute_me;
commit_events();
Expand All @@ -245,6 +247,9 @@ sub run_as_daemon {
terminate() if $CaughtSignal;
}

# If we found jobs, assume there are more. Don't wait to execute them.
next if $has_jobs;

# Flush out the publish_another queue.
if ($pkg eq PUB_PKG) {
eval {
Expand Down
8 changes: 8 additions & 0 deletions lib/Bric/Changes.pod
Expand Up @@ -36,6 +36,14 @@ Sponsored by Denison University. [David]
Added the C<--chunks> option to C<bric_queued>. Sponsored by Denison
University. [David]

=item *

Modified C<bric_queued> so that it only sleeps for C<--delay> seconds if it
executed no jobs. Otherwise it immediately runs again, on the assumption that
there will be more jobs that should be executed sooner rather than later. The
upshot is that files will now be distributed much sooner after publishling.
[David]

=back

=head1 Version 2.0.1 ()
Expand Down

0 comments on commit 9b73869

Please sign in to comment.