Answer the audit: Limited in its own module, the retry time's zone injected, file items 37 and 38

This commit is contained in:
2026-10-02 23:05:17 +02:00
parent a5e6e92f22
commit 8e8503345b
9 changed files with 46 additions and 17 deletions
+2 -10
View File
@@ -1,10 +1,9 @@
import dataclasses
import sys
import time
import typing
from loop_claude.effects import Effects
from loop_claude.failure import Failure
from loop_claude.limited import Limited
from loop_claude.stop import Stop
T = typing.TypeVar("T")
@@ -13,13 +12,6 @@ PAST_RESET = 120
UNKNOWN_RESET_POLL = 600
@dataclasses.dataclass(frozen=True)
class Limited:
"""claude hit a usage limit; said is claude's message about it, and resets_at is when the limit resets, in seconds since the epoch, or None when unknown."""
resets_at: int | None
said: str
def retried(who: str, attempt: typing.Callable[[], T | Failure | Limited], effects: Effects) -> T | Stop:
failures = 0
while True:
@@ -29,7 +21,7 @@ def retried(who: str, attempt: typing.Callable[[], T | Failure | Limited], effec
failures = 0
now = effects.now()
wait = limit_wait(result, now)
print(f"the {who} hit a usage limit ({result.said}); retrying at {time.strftime('%Y-%m-%d %H:%M %Z', time.localtime(now + wait))}", file=sys.stderr, flush=True)
print(f"the {who} hit a usage limit ({result.said}); retrying at {effects.local_time(now + wait)}", file=sys.stderr, flush=True)
effects.sleep(wait)
continue
if not isinstance(result, Failure):