Coverage for src/retrospeedlab/runner/crash_loop.py: 83%
12 statements
« prev ^ index » next coverage.py v7.16.2, created at 2026-12-04 00:01 +0000
« prev ^ index » next coverage.py v7.16.2, created at 2026-12-04 00:01 +0000
1import httpx
2from loguru import logger
4from retrospeedlab.runner.schedule import API_KEY_HEADER
6CRASH_LOOP_PATH = "/alerts/search-crash-loop"
9def report_crash_loop(client: httpx.Client, api_key: str, restarts: int, slug: str, exit_code: int) -> None:
10 stops = restarts + 1
11 logger.error(
12 f"Search crash loop: the {slug} search stopped {stops} times this turn, last with exit code {exit_code},"
13 " and waits for its next turn"
14 )
15 try:
16 response = client.post(
17 CRASH_LOOP_PATH,
18 json={"game": slug, "stops": stops, "exit_code": exit_code},
19 headers={API_KEY_HEADER: api_key},
20 )
21 response.raise_for_status()
22 except httpx.HTTPError as error:
23 logger.error(f"The backend did not take the {slug} search crash loop: {error}")