Always cancel the asyncio task?
parent
aa94ea5bcc
commit
6e646a6fa6
|
@ -55,7 +55,8 @@ def _run_asyncio_task(
|
||||||
or stream the result back to ``trio``.
|
or stream the result back to ``trio``.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
assert current_actor().is_infected_aio()
|
if not current_actor().is_infected_aio():
|
||||||
|
raise RuntimeError("`infect_asyncio` mode is not enabled!?")
|
||||||
|
|
||||||
# ITC (inter task comms)
|
# ITC (inter task comms)
|
||||||
from_trio = asyncio.Queue(qsize) # type: ignore
|
from_trio = asyncio.Queue(qsize) # type: ignore
|
||||||
|
@ -174,12 +175,12 @@ async def run_task(
|
||||||
else:
|
else:
|
||||||
raise
|
raise
|
||||||
|
|
||||||
except trio.Cancelled:
|
# except trio.Cancelled:
|
||||||
if not task.done():
|
# raise
|
||||||
|
finally:
|
||||||
|
# if not task.done():
|
||||||
task.cancel()
|
task.cancel()
|
||||||
|
|
||||||
raise
|
|
||||||
|
|
||||||
|
|
||||||
# TODO: explicit api for the streaming case where
|
# TODO: explicit api for the streaming case where
|
||||||
# we pull from the mem chan in an async generator?
|
# we pull from the mem chan in an async generator?
|
||||||
|
|
Loading…
Reference in New Issue