Asyncio exhausts connection pool
You asked an AI to speed up a Python script that enriches 50,000 users by calling an internal API and writing to Postgres. It parallelized with asyncio like this. Review the resource behavior.
It works for 100 users but falls over on the full set. Why, and how do you fix it?
Implement
simulate_bounded_pool(duration_ms: list[int], succeeded: list[bool], limit: int, release_on_error: bool) → list[int]Examples
in
[[100,100,100],[true,true,true],2,true]out[100,100,200]in
[[100,100,100],[true,true,true],5,true]out[100,100,100]in
[[50,50,50],[true,false,true],1,false]out[50,-1,-1]What a strong answer looks like
Treat the AI’s output as a draft to verify, not an answer to trust. Name the specific flaw and the input that triggers it, say how you’d catch it (tests, edge cases, reading critically), and how you’d re-prompt or decompose to get it right.
0:00 of about 18 min
Vibe & agentic: describe the solution in plain language (or narrate it) and the coach grades your approach.
Which questions mattered is sealed until you submit. Telling you now would just be handing over the edge cases.
Run or narrate your approach, then ask the coach.