This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author glangford
Recipients bquinlan, glangford, neologix, pitrou, vstinner
Date 2014-02-08.12:32:57
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1391862777.7.0.435411143425.issue20516@psf.upfronthosting.co.za>
In-reply-to
Content
> 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
History
Date User Action Args
2014-02-08 12:32:57glangfordsetrecipients: + glangford, bquinlan, pitrou, vstinner, neologix
2014-02-08 12:32:57glangfordsetmessageid: <1391862777.7.0.435411143425.issue20516@psf.upfronthosting.co.za>
2014-02-08 12:32:57glangfordlinkissue20516 messages
2014-02-08 12:32:57glangfordcreate