reliable · advanced · 45 min
Many workers, one dispatcher
Process a batch of claims in parallel with a cap on how many run at once, retries for the ones that fail, and no claim lost.
HANDS-ON LAB · YOU RUN IT ON YOUR MACHINE · 4 STEPS
-
Make 20 claim emails and process them one after another, timed
Run this to check
time uv run --with openai --with pydantic fanout.py claims/ --max 1You pass when
20 results and a total time. This is the number to beat.
Files you write
- claims/
- fanout.py
-
Run them four at a time
Run this to check
time uv run --with openai --with pydantic fanout.py claims/ --max 4You pass when
The same 20 results in well under the first time. The log never shows more than four in flight.
Files you write
- fanout.py
-
Make one call in five fail at random, and retry twice with a growing wait
A batch that reports 18 of 20 with no word on the other two is the failure that reaches customers.
Run this to check
uv run --with openai --with pydantic fanout.py claims/ --max 4 --chaos 0.2You pass when
Every claim ends as done or as failed after three tries. The count of both adds up to 20.
Files you write
- fanout.py
-
Print a summary: done, retried, failed, total cost
Run this to check
uv run --with openai --with pydantic fanout.py claims/ --max 4 --chaos 0.2 --summaryYou pass when
Four numbers, and the ids of any claim that failed for good.
Files you write
- fanout.py
No transcript here on purpose. This page does not show terminal output, because model answers differ from run to run. Each step says what a pass looks like; your own terminal is the proof.