Message210621
> 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 |
|
Date |
User |
Action |
Args |
2014-02-08 12:32:57 | glangford | set | recipients:
+ glangford, bquinlan, pitrou, vstinner, neologix |
2014-02-08 12:32:57 | glangford | set | messageid: <1391862777.7.0.435411143425.issue20516@psf.upfronthosting.co.za> |
2014-02-08 12:32:57 | glangford | link | issue20516 messages |
2014-02-08 12:32:57 | glangford | create | |
|