Back to problems

Implement a Connection Pool

Object-Oriented Programming · Airtable · Medium

Approach: Idle Connection List The pool separates two concerns: physical connection lifetime is owned by ConnectionPool, while checkout/check-in behavior is owned by the lightweight PoolConnection wrapper. The pool keeps a counter for connections currently checked out and a list of physical DBConnection objects that have been returned and are safe to reuse. get_connection first checks whether the pool is exhausted. If it is, the caller gets None. Otherwise, the pool prefers…

Checking your access…