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.
You build: fanout.py: 20 claims, at most four at a time, each with a final result.
- Python 3.11 or newer and uv
- An OpenRouter key (free models are enough)
- Lab 14 done (the extractor)
-
01Make 20 claim emails and process them one after another, timed
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.
-
02Run them four at a time
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.
-
03Make 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.
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.
-
04Print a summary: done, retried, failed, total cost
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.
The check runs on the computer, not on your word: a step passes when its command exits with 0 there.
Computers are not set up on this site yet. Run each command on your own machine and compare with "You pass when".
Commands run in labs/44-fan-out and may take up to 60 seconds each. Every command starts a new shell: put keys and settings in a .env file there, it is loaded each time.