Name the loop's states with one transition function, and inject its side effects

This commit is contained in:
2026-10-01 23:12:37 +02:00
parent d0ce3b2690
commit f385b563f0
16 changed files with 469 additions and 126 deletions
+3 -3
View File
@@ -1,13 +1,13 @@
import sys
import time
import typing
from loop_claude.effects import Effects
from loop_claude.outcome import Failure, Stop
T = typing.TypeVar("T")
def retried(who, attempt: typing.Callable[[], T | Failure]) -> T | Stop:
def retried(who, attempt: typing.Callable[[], T | Failure], effects: Effects) -> T | Stop:
failures = 0
while True:
failures += 1
@@ -17,4 +17,4 @@ def retried(who, attempt: typing.Callable[[], T | Failure]) -> T | Stop:
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)
effects.sleep(60)