Changeset 93 for trunk/oarutils


Ignore:
Timestamp:
Jan 24, 2013, 3:50:46 PM (11 years ago)
Author:
g7moreau
Message:
  • Create a thread by job to catch the end of that job
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/oarutils/oar-dispatch

    r92 r93  
    1010use Coro::Signal;
    1111use Coro::Semaphore;
    12 #use Coro::Timer qw(sleep);
     12use Coro::Timer qw(sleep);
    1313
    1414my $task = 0;
     
    7676         }
    7777      cede;
     78     
     79      # asynchrone guard for job end
     80      async {
     81         my $job_id = shift;
     82         GUARD:
     83         while () {
     84            sleep 15; # async, do not re-launch oarstat to fast
     85            my $is_finish = `oarstat -s -j $job_id`;
     86            chomp $is_finish;
     87            last GUARD if $is_finish =~ m/Terminated/;
     88            }
     89         delete $scheduled{$job_id};
     90         $job_active->down;
     91         $job_todo->down;
     92         } $job_id;
    7893      }
    79    }
     94   };
    8095
    8196async {
    8297   while () {
    83       for my $job_id (keys %scheduled) {
    84          my $is_finish = `oarstat -s -j $job_id`;
    85          chomp $is_finish;
    86          if ($is_finish =~ m/Terminated/) {
    87             delete $scheduled{$job_id};
    88             $job_active->down;
    89             $job_todo->down;
    90             }
    91          cede;
    92          }
     98#      for my $job_id (keys %scheduled) {
     99#         my $is_finish = `oarstat -s -j $job_id`;
     100#         chomp $is_finish;
     101#         if ($is_finish =~ m/Terminated/) {
     102#            delete $scheduled{$job_id};
     103#            $job_active->down;
     104#            $job_todo->down;
     105#            }
     106#         cede;
     107#         }
    93108
    94109      $finished->send if $job_todo->count == 0;
    95110      cede;
    96111      }
    97    }
     112   };
    98113
    99114cede;
Note: See TracChangeset for help on using the changeset viewer.