def try_io_operation(io_fn): if cfg.options.on_io_error in [1, 2]: max_tries = 100 else: max_tries = 0 wait_time = 6 tries = 0 done = False while not done: try: io_fn() break except RuntimeError: # e.g., generated by C++ code tries += 1 if tries > max_tries: logger.error("I/O operation failed, giving up after %s tries.", max_tries) raise logger.warn( "I/O operation failed, retrying in %s seconds. (Tries left: %s)", wait_time, max_tries - tries) time.sleep(wait_time) except: # any other exception bails out raise
def __init__(self, run, params, env, offset=0, *args, **kwargs): super(EnvironmentVariableController, self).__init__(run, params, *args, **kwargs) try: task_id = int(os.environ[env]) - offset except: logger.error("Could not read environment variable '%s'." % env) raise if task_id >= len(self.all_params): logger.warn("SGE task id is greater than the number of parameter sets.") self.my_params = [] else: self.my_params = [(task_id, self.all_params[task_id])]
def __init__(self, run, params, env, offset=0, *args, **kwargs): super(EnvironmentVariableController, self).__init__(run, params, *args, **kwargs) try: task_id = int(os.environ[env]) - offset except: logger.error("Could not read environment variable '%s'." % env) raise if task_id >= len(self.all_params): logger.warn( "SGE task id is greater than the number of parameter sets.") self.my_params = [] else: self.my_params = [(task_id, self.all_params[task_id])]
def try_io_operation(io_fn): if cfg.options.on_io_error in [1, 2]: max_tries = 100 else: max_tries = 0 wait_time = 6 tries = 0 done = False while not done: try: io_fn() break except RuntimeError: # e.g., generated by C++ code tries += 1 if tries > max_tries: logger.error("I/O operation failed, giving up after %s tries.", max_tries) raise logger.warn("I/O operation failed, retrying in %s seconds. (Tries left: %s)", wait_time, max_tries - tries) time.sleep(wait_time) except: # any other exception is an immediate error raise