
17 Dec
2011
17 Dec
'11
3:07 a.m.
On Sat, Dec 17, 2011 at 11:00 AM, Alon Horev alon@horev.net wrote:
Hello,
while I was implementing a connection pool i've noticed a pitfall of our beloved with statements:
with pool.get_connection() as conn: ....conn.execute(...) conn.execute(...) # the connection has been returned to the pool and does not belong to the user!
That's a bug in the connection pool implementation. If the underlying connection has been returned to the pool, the proxy returned by the context manager shouldn't work any more.
Try the above code structure with a file object and it will give you "IO operation on closed file".
Cheers, Nick.
--
Nick Coghlan | ncoghlan@gmail.com | Brisbane, Australia