BuildSeniorBackendAuto-graded
Fix a pool that leaks database connections
Scarce shared resources have to be reused, capped, and reliably handed back, which are the habits that prevent outages.pool.py hands out what is supposed to be a small, bounded set of reusable database connections. It does nothing of the kind: it opens a brand-new connection on every acquire, never reuses a released one, ignores its own size cap, and throws connections away on release. In production that leaks file descriptors and buries the database. Make ConnectionPool honour the contract in SPEC.md.45 min
python
You're done when
- When the pool is exhausted it raises the documented error rather than quietly opening another connection.
- A released connection is genuinely reused by the next acquire instead of being discarded.
- Using the pool as a context manager releases the connection automatically, including when the block raises.
What it measures
Back-end developmentManaging a finite shared resource correctly: lazy creation, a hard cap, and reuse rather than churn.
Performance optimizationRecognising why connection churn is expensive and what a pool is actually buying you.
Resource lifecycle disciplineGuaranteeing release on every path — including the failing one — which is where leaks are born.
Your environment
Terminal + editorA full shell in the browser
Claude CodePre-authenticated, no key setup
Isolated microVMYours alone, wiped afterwards
Start this lab
45 min
Start labYou'll sign in to Anthropos to start. The lab opens in a private cloud workspace with Claude Code ready to use.AI Labs is part of Anthropos Workforce. Not on your plan yet? Book a demo