def finish_pbs(multijob, finish_method): # first update to get more info about multijob jobs Printer.all.sep() Printer.all.out('Determining job status') multijob.update() # print jobs statuses with Printer.all.with_level(): multijob.print_status() Printer.console.sep() Printer.console.dyn(multijob.get_status_line()) result = ResultHolder() # use dynamic sleeper sleeper = DynamicSleep(min=300, max=5000, steps=5) # wait for finish while multijob.is_running(): Printer.console.dyn('Updating job status') multijob.update() Printer.console.dyn(multijob.get_status_line()) # if some jobs changed status add new line to dynamic output remains jobs_changed = multijob.get_all(status=JobState.COMPLETED) if jobs_changed: Printer.console.newline() Printer.all.sep() # get all jobs where was status update to COMPLETE state for job in jobs_changed: pypy = finish_method(job, not Printer.batched.is_muted()) if pypy: result.add(pypy) if jobs_changed: Printer.console.newline() # after printing update status lets sleep for a bit if multijob.is_running(): sleeper.sleep() Printer.all.sep() # print final result Printer.all.out(multijob.get_status_line()) Printer.all.out('All jobs finished') return result, multijob
def __init__(self, executor, period=.5): super(PyPy, self).__init__(name='pypy') self.executor = executor self.period = period self.case = None self.status_file = None self.extra = dict() self._short_sleep = False self.on_process_start = Event() self.on_process_complete = Event() self.on_process_update = Event() self.on_process_complete += self.generate_status_file self.monitor = monitors.MainMonitor(self) self.log = False self.custom_error = None # dynamic sleeper self.sleeper = DynamicSleep() # path to full output self.full_output = None