forked from goodboy/tractor
Proxy asyncio cancelleds as well
parent
793bcfb7d4
commit
aa24bbc11c
|
@ -101,7 +101,10 @@ def _run_asyncio_task(
|
||||||
"""Cancel the calling ``trio`` task on error.
|
"""Cancel the calling ``trio`` task on error.
|
||||||
"""
|
"""
|
||||||
nonlocal aio_err
|
nonlocal aio_err
|
||||||
|
try:
|
||||||
aio_err = task.exception()
|
aio_err = task.exception()
|
||||||
|
except asyncio.CancelledError as cerr:
|
||||||
|
aio_err = cerr
|
||||||
|
|
||||||
if aio_err:
|
if aio_err:
|
||||||
log.exception(f"asyncio task errorred:\n{aio_err}")
|
log.exception(f"asyncio task errorred:\n{aio_err}")
|
||||||
|
@ -233,18 +236,26 @@ async def run_task(
|
||||||
# raise aio_err
|
# raise aio_err
|
||||||
|
|
||||||
# Do we need this?
|
# Do we need this?
|
||||||
except BaseException as err:
|
except Exception as err:
|
||||||
# await tractor.breakpoint()
|
# await tractor.breakpoint()
|
||||||
aio_err = from_aio._err
|
aio_err = from_aio._err
|
||||||
|
|
||||||
|
# try:
|
||||||
if aio_err is not None:
|
if aio_err is not None:
|
||||||
# always raise from any captured asyncio error
|
# always raise from any captured asyncio error
|
||||||
raise err from aio_err
|
raise err from aio_err
|
||||||
else:
|
else:
|
||||||
raise
|
raise
|
||||||
|
# finally:
|
||||||
|
# if not task.done():
|
||||||
|
# task.cancel()
|
||||||
|
|
||||||
finally:
|
except trio.Cancelled:
|
||||||
|
if not task.done():
|
||||||
task.cancel()
|
task.cancel()
|
||||||
|
|
||||||
|
raise
|
||||||
|
|
||||||
|
|
||||||
# async def stream_from_task
|
# async def stream_from_task
|
||||||
# pass
|
# pass
|
||||||
|
|
Loading…
Reference in New Issue