forked from goodboy/tractor
Drop asyncio-cancelled-itself msg for now, report task names
parent
9e37bb22e1
commit
0b1c1ac568
|
@ -259,6 +259,7 @@ def _run_asyncio_task(
|
|||
nonlocal chan
|
||||
aio_err = chan._aio_err
|
||||
task_err: Optional[BaseException] = None
|
||||
tname = task.get_name()
|
||||
|
||||
# only to avoid ``asyncio`` complaining about uncaptured
|
||||
# task exceptions
|
||||
|
@ -268,9 +269,10 @@ def _run_asyncio_task(
|
|||
task_err = terr
|
||||
|
||||
if isinstance(terr, CancelledError):
|
||||
log.cancel(f'`asyncio` task cancelled: {task.get_name()}')
|
||||
log.cancel(
|
||||
f'infected `asyncio` task cancelled: {tname}')
|
||||
else:
|
||||
log.exception(f'`asyncio` task: {task.get_name()} errored')
|
||||
log.exception(f'`asyncio` task: {tname} errored')
|
||||
|
||||
assert type(terr) is type(aio_err), 'Asyncio task error mismatch?'
|
||||
|
||||
|
@ -285,21 +287,24 @@ def _run_asyncio_task(
|
|||
# We might want to change this in the future though.
|
||||
from_aio.close()
|
||||
|
||||
if type(aio_err) is CancelledError:
|
||||
log.cancel("infected task was cancelled")
|
||||
# if type(aio_err) is CancelledError:
|
||||
# if not task_err:
|
||||
# log.cancel(
|
||||
# f"infected task {tname} cancelled itself, was not ``trio``"
|
||||
# )
|
||||
|
||||
# TODO: show that the cancellation originated
|
||||
# from the ``trio`` side? right?
|
||||
# if cancel_scope.cancelled:
|
||||
# raise aio_err from err
|
||||
|
||||
elif task_err is None:
|
||||
if task_err is None:
|
||||
assert aio_err
|
||||
aio_err.with_traceback(aio_err.__traceback__)
|
||||
msg = ''.join(traceback.format_exception(type(aio_err)))
|
||||
log.error(
|
||||
f'infected task errorred:\n{msg}'
|
||||
)
|
||||
# msg = ''.join(traceback.format_exception(type(aio_err)))
|
||||
# log.error(
|
||||
# f'infected task errorred:\n{msg}'
|
||||
# )
|
||||
|
||||
# raise any ``asyncio`` side error.
|
||||
raise aio_err
|
||||
|
@ -392,8 +397,8 @@ async def run_task(
|
|||
|
||||
) -> Any:
|
||||
'''
|
||||
Run an ``asyncio`` async function or generator in a task, return
|
||||
or stream the result back to ``trio``.
|
||||
Run an ``asyncio`` async function or generator in a new task, block
|
||||
and return the result back to ``trio``.
|
||||
|
||||
'''
|
||||
# simple async func
|
||||
|
|
Loading…
Reference in New Issue