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 nmatravolgyi
Recipients asvetlov, nmatravolgyi, yselivanov
Date 2021-03-03.21:33:14
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1614807194.9.0.422304083833.issue43389@roundup.psfhosted.org>
In-reply-to
Content
One more thing. I've figured out that I can fix the cancellation around the asyncio.wait_for() with asyncio.shield() like:

try:
    await asyncio.shield(wf := asyncio.ensure_future(asyncio.wait_for(self.event.wait(), timeout=60.0)))
except asyncio.CancelledError:
    wf.cancel()
    result = await asyncio.gather(wf, return_exceptions=True)
    # here I know there is a cancellation AND I might have a result as well!
    raise

However I don't like the idea of writing all that boilerplate for every wait_for usage. I still might be overlooking something, but at least I have adequate workarounds.

I'm curious what the consensus will be on this issue. I'm certain it should be documented though. Right now there is no mention of ignoring/eating a cancellation.
History
Date User Action Args
2021-03-03 21:33:14nmatravolgyisetrecipients: + nmatravolgyi, asvetlov, yselivanov
2021-03-03 21:33:14nmatravolgyisetmessageid: <1614807194.9.0.422304083833.issue43389@roundup.psfhosted.org>
2021-03-03 21:33:14nmatravolgyilinkissue43389 messages
2021-03-03 21:33:14nmatravolgyicreate