contextlib.contextmanager and try/finally

2012-01-11 Thread johannh
I'm trying to write a context manager to handle database connections, under the principle that I should not rely on CPython's reference-counting semantics to clean up scarce resources, like connections. I wrote: @contexlib.contextmanager def ensure_connection(con=None): con_created = False

Re: contextlib.contextmanager and try/finally

2012-01-11 Thread johannh
On Wednesday, January 11, 2012 11:20:19 AM UTC-6, Ian wrote: > > Second, I believe that passage is not referring to the contextmanager > decorator specifically, but more generally to the changes that were > made to allow generators to yield from within a try-finally construct > (previously this wo