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
  1. Step 1 of 4

    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 1

    You pass when

    20 results and a total time. This is the number to beat.

    Files you write

    • claims/
    • fanout.py
  2. Step 2 of 4

    Run them four at a time

    Run this to check

    time uv run --with openai --with pydantic fanout.py claims/ --max 4

    You 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
  3. Step 3 of 4

    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.2

    You 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
  4. Step 4 of 4

    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 --summary

    You 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.