Message258045
It was a bit more subtle. I think like this:
def f():
with some_lock:
yield 0
yield 1
def g():
with another_lock:
it = f()
for i in it:
raise
We determined that another_lock was freed *before* some_lock. This is because the local variable 'it' keeps the generator object returned by f() alive until after the with-block in g() has released another_lock.
I think this does not strictly require f to be a generator -- it's any kind of closable resource that only gets closed by its destructor.
The solution is to add a try/finally that calls it.close() before leaving the with-block in g().
Hope this helps. |
|
Date |
User |
Action |
Args |
2016-01-12 00:40:11 | gvanrossum | set | recipients:
+ gvanrossum, vstinner, benhoyt, martin.panter, serhiy.storchaka |
2016-01-12 00:40:11 | gvanrossum | set | messageid: <1452559211.7.0.783884488227.issue25994@psf.upfronthosting.co.za> |
2016-01-12 00:40:11 | gvanrossum | link | issue25994 messages |
2016-01-12 00:40:11 | gvanrossum | create | |
|