コード例 #1
0
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
コード例 #2
0
ファイル: controller.py プロジェクト: MicroMagnum/MicroMagnum
    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])]
コード例 #3
0
ファイル: controller.py プロジェクト: cmuhai/MicroMagnum
    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])]
コード例 #4
0
ファイル: io_tools.py プロジェクト: micromagnetics/magnum.fd
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