Message311509
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:15 | njs | set | recipients:
+ njs, giampaolo.rodola, asvetlov, yselivanov |
2018-02-02 20:01:15 | njs | set | messageid: <1517601675.34.0.467229070634.issue32751@psf.upfronthosting.co.za> |
2018-02-02 20:01:15 | njs | link | issue32751 messages |
2018-02-02 20:01:15 | njs | create | |
|