def prepare_contest(atcoder_client: AtCoderClient, contest_id: str, config: Config, retry_delay_secs: float=1.5, retry_max_delay_secs: float=60, retry_max_tries: int=10):
    attempt_count = 1
    while True:
        try:
            problem_list = atcoder_client.download_problem_list(Contest(contest_id=contest_id))
            break
        except PageNotFoundError:
            if (0 < retry_max_tries < attempt_count):
                raise EnvironmentInitializationError
            logger.warning('Failed to fetch. Will retry in {} seconds. (Attempt {})'.format(retry_delay_secs, attempt_count))
            time.sleep(retry_delay_secs)
            retry_delay_secs = min((retry_delay_secs * 2), retry_max_delay_secs)
            attempt_count += 1
    tasks = [(atcoder_client, problem, config) for problem in problem_list]
    output_splitter()
    if config.etc_config.parallel_download:
        thread_pool = Pool(processes=cpu_count())
        thread_pool.map(func, tasks)
    else:
        for argv in tasks:
            try:
                func(argv)
            except Exception:
                print(traceback.format_exc(), file=sys.stderr)
                pass
    if (config.postprocess_config.exec_cmd_on_contest_dir is not None):
        contest_dir_path = os.path.join(config.code_style_config.workspace_dir, contest_id)
        logger.info(_message_on_execution(contest_dir_path, config.postprocess_config.exec_cmd_on_contest_dir))
        config.postprocess_config.execute_on_contest_dir(contest_dir_path)
def prepare_contest(atcoder_client: AtCoderClient, contest_id: str, config: Config, retry_delay_secs: float=1.5, retry_max_delay_secs: float=60, retry_max_tries: int=10):
    attempt_count = 1
    while True:
        try:
            problem_list = atcoder_client.download_problem_list(Contest(contest_id=contest_id))
            break
        except PageNotFoundError:
            if (0 < retry_max_tries < attempt_count):
                raise EnvironmentInitializationError
            logger.warning('Failed to fetch. Will retry in {} seconds. (Attempt {})'.format(retry_delay_secs, attempt_count))
            time.sleep(retry_delay_secs)
            retry_delay_secs = min((retry_delay_secs * 2), retry_max_delay_secs)
            attempt_count += 1
    tasks = [(atcoder_client, problem, config) for problem in problem_list]
    output_splitter()
    if config.etc_config.parallel_download:
        thread_pool = Pool(processes=cpu_count())
        thread_pool.map(func, tasks)
    else:
        for argv in tasks:
            try:
                func(argv)
            except Exception:
                print(traceback.format_exc(), file=sys.stderr)
                pass
    if (config.postprocess_config.exec_cmd_on_contest_dir is not None):
        contest_dir_path = os.path.join(config.code_style_config.workspace_dir, contest_id)
        logger.info(_message_on_execution(contest_dir_path, config.postprocess_config.exec_cmd_on_contest_dir))
        config.postprocess_config.execute_on_contest_dir(contest_dir_path)