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 njs
Recipients asvetlov, dfee, njs, yselivanov
Date 2018-09-20.20:34:17
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1537475657.78.0.956365154283.issue34730@psf.upfronthosting.co.za>
In-reply-to
Content
Part of the issue here is the one discussed in bpo-30773 / bpo-32526: async generators allow themselves to be re-entered while another asend/athrow/aclose call is in progress, and it causes weird and confusing results. So at a minimum, trying to call aclose while another task is calling asend should make aclose raise an error saying that the generator is already busy.

Of course the OP wants to go further and have aclose actually trigger a cancellation of any outstanding asend/athrow. I see the intuition here, but unfortunately I don't think this can work. Doing a cancellation requires some intimate knowledge of the coroutine runner. You can't just throw in an exception; you also have to unwind the task state. (Eg in the example with 'event.wait', you need to somehow tell the event object that this task is no longer waiting for it, so it shouldn't be notified when the event occurrs.)

So I think we just need to fix ag_running and then recommend people find other ways to interrupt running async generators.
History
Date User Action Args
2018-09-20 20:34:17njssetrecipients: + njs, asvetlov, yselivanov, dfee
2018-09-20 20:34:17njssetmessageid: <1537475657.78.0.956365154283.issue34730@psf.upfronthosting.co.za>
2018-09-20 20:34:17njslinkissue34730 messages
2018-09-20 20:34:17njscreate