Example #1
0
def cleanup_loop():
    last_cleanup = 0
    last_run_check = 0
    last_runner_check = 0
    while True:
        with runtime.is_active_condition:
            while not runtime.is_active:
                runtime.is_active_condition.wait()

        while runtime.is_active:
            if runner_check_interval < time.time() - last_runner_check:
                try:
                    AnarchyRunner.manage_runners(runtime)
                    last_runner_check = time.time()
                except:
                    operator_logger.exception(
                        'Error in AnarchyRunner.manage_runners!')

            if cleanup_interval < time.time() - last_cleanup:
                try:
                    AnarchyGovernor.cleanup(runtime)
                    last_cleanup = time.time()
                except:
                    operator_logger.exception(
                        'Error in AnarchyGovernor.cleanup!')

            if run_check_interval < time.time() - last_run_check:
                try:
                    AnarchyRun.manage_active_runs(runtime)
                    last_run_check = time.time()
                except:
                    operator_logger.exception(
                        'Error in AnarchyRun.manage_active_runs!')

            time.sleep(5)
Example #2
0
def main_loop():
    last_cleanup = 0
    last_run_check = 0
    last_runner_check = 0
    while True:
        with runtime.is_active_condition:
            while not runtime.is_active:
                runtime.is_active_condition.wait()

        if runtime.running_all_in_one:
            start_runner_process()
        elif not AnarchyRunner.get('default'):
            init_default_runner()

        while runtime.is_active:
            AnarchyAction.start_actions(runtime)

            if cleanup_interval < time.time() - last_cleanup:
                try:
                    AnarchyGovernor.cleanup(runtime)
                    last_cleanup = time.time()
                except:
                    operator_logger.exception(
                        'Error in AnarchyGovernor.cleanup!')

            if run_check_interval < time.time() - last_run_check:
                try:
                    AnarchyRun.manage_active_runs(runtime)
                    last_run_check = time.time()
                except:
                    operator_logger.exception(
                        'Error in AnarchyRun.manage_active_runs!')

            if runner_check_interval < time.time() - last_runner_check:
                try:
                    AnarchyRunner.manage_runners(runtime)
                    last_runner_check = time.time()
                except:
                    operator_logger.exception(
                        'Error in AnarchyRunner.manage_runners!')

            time.sleep(1)