Files
libretro/scripts/profiling/quota.py
T
Abdessamad Derraz 83e810d1b3 fix: let core.upstream refuse requests offline
RETROBIOS_OFFLINE was read by six callers and never by the network
gateway: a caller that did not pass offline=True sent the request,
untokened. core.offline holds the rule, open_retrying refuses with
OfflineError and the cached reads answer as an offline run. The callers
read the same predicate, and the tests that fake the network clear the
variable for themselves (tests.ONLINE).
2026-11-24 00:20:03 +01:00

25 lines
720 B
Python

"""The anonymous GitHub quota a profile pass has to fit in."""
from __future__ import annotations
import sys
from core.github import github_token
from core.offline import run_is_offline
ANON_QUOTA = 60
def check_quota(count: int, offline: bool) -> None:
"""Refuse a run the anonymous quota cannot carry to completion."""
if run_is_offline(offline) or github_token():
return
if count * 5 > ANON_QUOTA:
print(
f"{count} profiles need roughly {count * 5} API calls, the anonymous "
f"quota is {ANON_QUOTA} per hour. Log in with `gh auth login`, set "
"GITHUB_TOKEN, or use --offline.",
file=sys.stderr,
)
raise SystemExit(1)