Message325704
I've worked around this problem by doing something like this:
async def close_cancelling(agen):
while True:
try:
task = asyncio.ensure_future(agen.__anext__())
await task
yield task.result()
except (GeneratorExit, StopAsyncIteration):
await agen.aclose()
task.cancel()
break
async def run():
try:
async for v in close_cancelling(agen):
received.append(v)
except asyncio.CancelledError:
# handle finalization
pass
Though, I'm still convinced that `aclose()` should call raise `StopAsyncIteration` on `agen.ag_await` |
|
Date |
User |
Action |
Args |
2018-09-19 06:12:34 | dfee | set | recipients:
+ dfee, asvetlov, yselivanov |
2018-09-19 06:12:34 | dfee | set | messageid: <1537337554.33.0.956365154283.issue34730@psf.upfronthosting.co.za> |
2018-09-19 06:12:34 | dfee | link | issue34730 messages |
2018-09-19 06:12:34 | dfee | create | |
|