platinummonkey/rexpro-python — pull request #11 by nvie (2014-09-10 18:07:33+00:00)
Title: Fix: always return connections back to the pool

This caught us badly in a long-running process where a bunch of failures accumulated, which led to the connection pool filling up. The processes using the connection had ended, and new processes could not acquire any of the connections, effectively deadlocking the processes.

This patch makes sure that connections are always put back into the pool at the end of the context manager's body, even in case of failure.