Retry the worker and the judge through one counter, in retry.py

This commit is contained in:
2026-09-29 11:02:57 +02:00
parent 6c09cadfa3
commit fb221787d6
5 changed files with 27 additions and 44 deletions
+11 -6
View File
@@ -1,11 +1,16 @@
import itertools
import sys
import time
from loop_claude.outcome import Stop
from loop_claude.outcome import Failure, Stop
def stop_or_sleep_a_minute(who, failures, reason):
if failures == 3:
return Stop(1, f"the {who} failed three times running: {reason}")
print(f"retrying the {who} in a minute: {reason}", file=sys.stderr)
time.sleep(60)
def retried(who, attempt):
for failures in itertools.count(1):
result = attempt()
if not isinstance(result, Failure):
return result
if failures == 3:
return Stop(1, f"the {who} failed three times running: {result.reason}")
print(f"retrying the {who} in a minute: {result.reason}", file=sys.stderr)
time.sleep(60)