Job 1788376104684

Command: python -c "import inspect,importlib.util;spec=importlib.util.spec_from_file_location('ll','low_latency_relay_v4diag.py');m=importlib.util.module_from_spec(spec);spec.loader.exec_module(m);print(inspect.getsource(m.process_command));print(inspect.getsource(m.run_loop))"
Directory: projects
Status: SUCCESS
Exit code: 0

Cancel Job Rerun Command Refresh

def process_command(cfg, command):
    sr.log(f"claimed command id={command.get('id')} action={command.get('action')}")
    task_id = ''
    try:
        task_id = str(json.loads(command.get('payload_json') or '{}').get('task_id', ''))
    except (TypeError, ValueError):
        pass
    sr.record_task_event(task_id, 'command_started', command_id=command.get('id'), action=command.get('action'))
    try:
        command_result = sr.execute_command(cfg, command)
        sr.record_task_event(
            task_id,
            'command_completed' if command_result.get('status') == 'done' else 'command_failed',
            command_id=command.get('id'), action=command.get('action'),
            relay_status=command_result.get('status'), http_status=command_result.get('http_status'),
        )
        sr.send_result(cfg, command_result)
    except Exception as exc:
        sr.record_task_event(task_id, 'command_failed', command_id=command.get('id'), action=command.get('action'), error=type(exc).__name__)
        sr.send_result(cfg, sr.result(command.get('id', ''), 'error', '', '', str(exc), time.time()))

def run_loop():
    cfg = sr.require_config()
    sr.log(f'latency-isolation relay starting revision={LIVE_REVISION} poll_workers=1 maintenance=disabled')
    while True:
        try:
            status, data = sr.http_json(sr.web_app_url(cfg, 'poll'), timeout=45)
            if status != 200:
                sr.log(f'LL3T poll http={status}')
                time.sleep(ERROR_BACKOFF_SECONDS)
                continue
            command = data.get('command')
            trace(f'poll status={status} command={str(command.get("id")) if command else "NONE"}')
            if command:
                process_command(cfg, command)
        except KeyboardInterrupt:
            sr.log('LL3T stopped by keyboard interrupt')
            return
        except Exception as exc:
            sr.log(f'LL3T poll error: {type(exc).__name__}: {exc}')
            time.sleep(ERROR_BACKOFF_SECONDS)