[issue20516] Concurrent.futures base concurrency improvement (with patch)
Glenn Langford
report at bugs.python.org
Sat Feb 8 13:32:57 CET 2014
Glenn Langford added the comment:
> if the future is cancelled or finished, control is yielded back to the caller with the condition's lock held.
Hmmm...I don't agree. I assume you are looking at this code:
with f._condition: # Lock the Future; yield if completed or add our Waiter
if f._state in [CANCELLED_AND_NOTIFIED, FINISHED]:
yield f
Note that the context manager will be called in this case to release the lock before f is yielded to the caller.
class MiniContext():
def __init__(self):
pass
def __enter__(self):
print('Hello')
def __exit__(self, *args):
print('Goodbye')
def gen():
with MiniContext():
yield 1
print(next(gen()))
prints:
Hello
Goodbye
1
----------
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue20516>
_______________________________________
More information about the Python-bugs-list
mailing list