mongodb/mongo-python-driver — pull request #163 by reversefold (2013-03-17 08:21:42+00:00)
Title: PYTHON-436 Add support for a maximum number of open connections

This patch adds a semaphore to keep track of sockets opened and released from the pool in order to be able to enforce a maximum number of open connections. I've also fixed a few places where sockets were being leaked from the pool (never returned) and an extra socket return in a test.

Timeout support for the semaphore is added in this patch to support connection timeouts properly.

Changes have been made to make sure that internal functions can always get a socket from the pool. even if it's at max, so it's possible for more than the configured max to be opened, but these "forced" connections are still tracked and should always be returned.