Skip to main content
πŸ”’ Preview mode. The first 15 Foundations lessons are free; this one is Pro. Start a 7-day trial to unlock the editor, AI hints and the the rest of the curriculum. Card required, cancel any time in Dashboard.Start 7-day trial β†’
⚑
← Coursesβ€ΊFastAPI ProductionModule 3 Β· Async + Background Β· Recapβ€ΊπŸŽ― Review: FastAPI module 3 recapscenario64 / 105
+80 XP
Task
Build a small `bg_job_runner(tasks)` that ties 4 module-3 ideas together: Each `task` is a dict with `{"id": str, "work": int, "fail": bool}`. The runner must: 1. **Iterate deterministically** β€” process in list order so tests pass. 2. **Retry up to 2 times** on tasks with `fail=True`. On the 3rd attempt the task succeeds (simulating a flaky dep that eventually responds). 3. **Track each task's final state** β€” `{"id": id, "attempts": n, "result": work*10}`. 4. **Return** the list of results in the original order. (We avoid real `async` here so the recap stays Pyodide-friendly; the retry semantics are the actual idea you carry into module 4.)
✏️ Write your code here
🐍
Loading Python...
One-time download (~1 MB). Then it runs instantly.
πŸ“Š Result
Press Run to see result...

πŸ’¬ Discussion

Be the first to ask a question or share a tip.
Sign in to join the discussion. Reading is free.
Loading discussion…