Changeset 1870

Show
Ignore:
Timestamp:
04/13/08 04:23:51 (22 months ago)
Author:
bchoate
Message:

Prevent fatal error when attempting to use TheSchwartz without List::Util module. BugId:77208

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • branches/release-34/tools/run-periodic-tasks

    r1407 r1870  
    2626my $sleep     = 5; 
    2727my $help      = 0; 
    28 # my $sync      = 0; 
    29 # my $rsync_opt = ''; 
    3028my $load      = 10; 
    3129my $verbose   = 0; 
     
    3533    "daemon"      => \$daemonize, 
    3634    "sleep=i"     => \$sleep, 
    37     # "help|?"      => \$help, 
    38     # "throttle=i"  => \%throttle, 
    39     # "worker=s"    => \$worker, 
    40     # "sync"        => \$sync, 
    41     # "to|target=s" => \@target, 
    42     # "rsync=s"     => \$rsync_opt, 
    4335    "load=i"      => \$load, 
    4436    "scoreboard=s"=> \$scoreboard, 
     
    5143$cfg{prioritize} = 1; 
    5244 
    53 require MT::TheSchwartz; 
    54 my $client = MT::TheSchwartz->new(%cfg); 
    55 no warnings 'once'; 
    56 $TheSchwartz::FIND_JOB_BATCH_SIZE = $load; 
     45my $client = eval { 
     46    require MT::TheSchwartz; 
     47    my $c = MT::TheSchwartz->new(%cfg); 
     48    no warnings 'once'; 
     49    $TheSchwartz::FIND_JOB_BATCH_SIZE = $load; 
     50    $c; 
     51}; 
     52if ((my $error = $@) && $verbose) { 
     53    print STDERR "Error initializing TheSchwartz: $error\n"; 
     54} 
    5755 
    58 if ($daemonize) { 
     56if ($daemonize && $client) { 
    5957    $client->work_periodically($sleep); 
    6058} else { 
    6159    # First, run periodic tasks 
    6260    $mt->run_tasks(); 
    63     $client->work_until_done; 
     61    $client->work_until_done if $client; 
    6462} 
    6563