Changeset 97 for trunk/oarutils


Ignore:
Timestamp:
Jan 26, 2013, 11:06:54 AM (11 years ago)
Author:
g7moreau
Message:
  • Clean code and add comments
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/oarutils/oar-dispatch

    r96 r97  
    2424my $sig_transmit;
    2525my $sig_checkpoint = 'USR2';
     26my $brake = 5; # five second time brake
    2627
    2728Getopt::Long::GetOptions(
     
    3637   'transmit'     => \$sig_transmit,
    3738   'kill=s'       => \$sig_checkpoint,
     39   'brake=i'      => \$brake,
    3840   ) || pod2usage(-verbose => 0);
    3941pod2usage(-verbose => 2) if $help;
     
    213215         while () {
    214216            cede;
    215             $timer = AE::now + 5;
    216             while ( AE::now < $timer ) { AE::now_update; cede; }
     217
     218            # wait to not re-launch oarstat to fast
     219            # equivalent to sleep $brake
     220            $timer = AE::now + $brake;
     221            while ( AE::now < $timer ) {
     222               # force update of AE time
     223               AE::now_update;
     224               cede;
     225               }
     226
    217227            my $is_finish = `oarstat -s -j $job_id`;
    218228            chomp $is_finish;
     
    223233            $scheduled{$job_id}->{name}, $job_id, time;
    224234
    225             # Job non finish, just suspend if received checkpoint signal
    226             $msg =~ s/^end\s+job/suspend job/
    227                if $sig_transmit and $oar_checkpoint->count() > 0;
    228 
    229             $log_h->print($msg) if $logtrace;
    230             print($msg) if $verbose;
     235         # Job non finish, just suspend if received checkpoint signal
     236         $msg =~ s/^end\s+job/suspend job/
     237            if $sig_transmit and $oar_checkpoint->count() > 0;
     238
     239         $log_h->print($msg) if $logtrace;
     240         print($msg) if $verbose;
    231241
    232242         $job_active->down;
     
    235245         }
    236246      }
    237    };
     247   }
    238248
    239249async {
    240250   while () {
    241 #      for my $job_id (keys %scheduled) {
    242 #         my $is_finish = `oarstat -s -j $job_id`;
    243 #         chomp $is_finish;
    244 #         if ($is_finish =~ m/Terminated/) {
    245 #            delete $scheduled{$job_id};
    246 #            $job_active->down;
    247 #            $job_todo->down;
    248 #            }
    249 #         cede;
    250 #         }
    251 
    252251      # checkpointing ! just finishing running job and quit
    253252      $finished->send if $oar_checkpoint->count() > 0 and scalar(keys(%scheduled)) == 0;
     
    256255      cede;
    257256      }
    258    };
     257   }
    259258
    260259cede;
Note: See TracChangeset for help on using the changeset viewer.