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 <[email protected]>
<http://bugs.python.org/issue20516>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com