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 <1517601675.34.0.467229070634.issue32751@psf.upfronthosting.co.za>
In-reply-to
Content
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.)
History
Date User Action Args
2018-02-02 20:01:15njssetrecipients: + njs, giampaolo.rodola, asvetlov, yselivanov
2018-02-02 20:01:15njssetmessageid: <1517601675.34.0.467229070634.issue32751@psf.upfronthosting.co.za>
2018-02-02 20:01:15njslinkissue32751 messages
2018-02-02 20:01:15njscreate