betting_combat.consumers.cito.limits
What the Cito client may spend: calls per minute (RateLimiter) and the plan’s month
(CallBudget).
The Starter plan ($15) allows 10,000 calls a month at 10 a minute (the server lets bursts of
up to 30 through; never relied on). Every call counts, a warming answer and a failed attempt
included, so the budget counts attempts, not answers. The month’s remainder is Cito’s own
count (X-RateLimit-Monthly-Remaining on every answer): the budget refuses once the month is
spent, and only then.
Classes
CallBudget
The calls a run makes, counted (used, by_endpoint): none once Cito’s monthly
remainder is spent; no other limit.
observe
observe(headers: Mapping[str, str]) -> NoneRead the month’s remainder from an answer’s headers (when it carries one).
spend
spend(endpoint: str) -> NoneCount one attempt at endpoint, or raise CitoBudgetError (nothing counted).
CitoBudgetError
Bases: RuntimeError
The budget refuses the call (the month’s calls spent).
RateLimiter
At most per_minute calls in any window_s (60 s): a caller over the limit waits
for the oldest call in the window to age out. defer holds every caller back for a
while (a 429’s Retry-After).
acquire
acquire() -> floatWait for a slot; returns the seconds waited.
defer
defer(seconds: float) -> NoneNo call starts before seconds from now.