psycopg/psycopg2 — pull request #17 by irrelative (2014-06-20 20:36:01+00:00)
Title: Add context manager for connection pool for use with the with statement

Hi devs!

I really enjoy using context managers for connections and cursors, but it's kind of a pain to do this with connection pooling. This adds the ability to do this, and works like so:

```
pool = SimpleConnectionPool(...)

def work():
with pool() as conn:
# Use connection normally, it'll automatically be put back into the pool when complete
```

I'm open to suggestions with the interface -- the `__call__` seemed the least contentious with the existing method names. Let me know what you think.

Cheers,
Justin