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, giampaolo.rodola, njs, yselivanov
Date 2018-02-02.20:01:15
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
Currently, if you use asyncio.wait_for(future, timeout=....) and the timeout expires, then it (a) cancels to the future, and then (b) returns. This is fine if the future is a Future, because Future.cancel is synchronous and completes immediately. But if the future is a Task, then Task.cancel merely requests cancellation, and it will complete later (or not). In particular, this means that wait_for(coro, ...) can return with the coroutine still running, which is surprising.

(Originally encountered by Alex Grönholm, who was using code like

async with aclosing(agen):
    await wait_for(agen.asend(...), timeout=...)

and then confused about why the call to agen.aclose was raising an error complaining that agen.asend was still running. Currently this requires an async_generator based async generator to trigger; with a native async generator, the problem is masked by bpo-32526.)
Date User Action Args
2018-02-02 20:01:15njssetrecipients: + njs, giampaolo.rodola, asvetlov, yselivanov
2018-02-02 20:01:15njssetmessageid: <>
2018-02-02 20:01:15njslinkissue32751 messages
2018-02-02 20:01:15njscreate