def watch_and_wait(self, poll_interval=10, idle_log_timeout=None, kill_on_timeout=False, stash_log_method=None, tag_instances=False, kill_on_exception=True, **kwargs): """This provides shortcut access to the wait_for_complete_function.""" try: res = wait_for_complete(self._job_queue, job_list=self.job_list, job_name_prefix=self.basename, poll_interval=poll_interval, idle_log_timeout=idle_log_timeout, kill_on_log_timeout=kill_on_timeout, stash_log_method=stash_log_method, tag_instances=tag_instances, **kwargs) except (BaseException, KeyboardInterrupt) as e: logger.error("Exception in wait_for_complete:") logger.exception(e) if kill_on_exception: logger.info("Killing all my jobs...") kill_all(self._job_queue, kill_list=self.job_list, reason='Exception in monitor, jobs aborted.') raise e return res
def wait_thread(monitor): try: wait_res = monitor.watch_and_wait( poll_interval=poll_interval, idle_log_timeout=idle_log_timeout, kill_on_log_timeout=kill_on_timeout, stash_log_method=stash_log_method, tag_instances=tag_instances, **kwargs) except (BaseException, KeyboardInterrupt) as e: logger.error("Exception in wait_for_complete:") logger.exception(e) if kill_on_exception: logger.info("Killing all my jobs...") kill_all(monitor.queue_name, kill_list=self.job_list, reason='Exception in monitor, jobs aborted.') raise e return wait_res