Log "out-of-layer" cancellation in `._rpc._invoke()`
Similar to what was just changed for `Context.repr_state`, when the child task is cancelled but by a different "layer" of the runtime (i.e. a `Portal.cancel_actor()` / `SIGINT`-to-process canceller) we don't dump a traceback instead just `log.cancel()` emit.final_eg_refinements
parent
967d0e4836
commit
2ec3ff46cd
|
@ -661,7 +661,7 @@ async def _invoke(
|
||||||
tn: Nursery
|
tn: Nursery
|
||||||
rpc_ctx_cs: CancelScope
|
rpc_ctx_cs: CancelScope
|
||||||
async with (
|
async with (
|
||||||
collapse_eg(),
|
collapse_eg(hide_tb=False),
|
||||||
trio.open_nursery() as tn,
|
trio.open_nursery() as tn,
|
||||||
msgops.maybe_limit_plds(
|
msgops.maybe_limit_plds(
|
||||||
ctx=ctx,
|
ctx=ctx,
|
||||||
|
@ -854,24 +854,44 @@ async def _invoke(
|
||||||
f'after having {ctx.repr_state!r}\n'
|
f'after having {ctx.repr_state!r}\n'
|
||||||
)
|
)
|
||||||
if merr:
|
if merr:
|
||||||
|
|
||||||
logmeth: Callable = log.error
|
logmeth: Callable = log.error
|
||||||
if isinstance(merr, ContextCancelled):
|
if (
|
||||||
logmeth: Callable = log.runtime
|
# ctxc: by `Context.cancel()`
|
||||||
|
isinstance(merr, ContextCancelled)
|
||||||
|
|
||||||
if not isinstance(merr, RemoteActorError):
|
# out-of-layer cancellation, one of:
|
||||||
tb_str: str = ''.join(traceback.format_exception(merr))
|
# - actorc: by `Portal.cancel_actor()`
|
||||||
|
# - OSc: by SIGINT or `Process.signal()`
|
||||||
|
or (
|
||||||
|
isinstance(merr, trio.Cancelled)
|
||||||
|
and
|
||||||
|
ctx.canceller
|
||||||
|
)
|
||||||
|
):
|
||||||
|
logmeth: Callable = log.cancel
|
||||||
|
descr_str += (
|
||||||
|
f' with {merr!r}\n'
|
||||||
|
)
|
||||||
|
|
||||||
|
elif (
|
||||||
|
not isinstance(merr, RemoteActorError)
|
||||||
|
):
|
||||||
|
tb_str: str = ''.join(
|
||||||
|
traceback.format_exception(merr)
|
||||||
|
)
|
||||||
descr_str += (
|
descr_str += (
|
||||||
f'\n{merr!r}\n' # needed?
|
f'\n{merr!r}\n' # needed?
|
||||||
f'{tb_str}\n'
|
f'{tb_str}\n'
|
||||||
f'\n'
|
|
||||||
f'scope_error:\n'
|
|
||||||
f'{scope_err!r}\n'
|
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
descr_str += f'\n{merr!r}\n'
|
descr_str += (
|
||||||
|
f'{merr!r}\n'
|
||||||
|
)
|
||||||
else:
|
else:
|
||||||
descr_str += f'\nwith final result {ctx.outcome!r}\n'
|
descr_str += (
|
||||||
|
f'\n'
|
||||||
|
f'with final result {ctx.outcome!r}\n'
|
||||||
|
)
|
||||||
|
|
||||||
logmeth(
|
logmeth(
|
||||||
f'{message}\n'
|
f'{message}\n'
|
||||||
|
|
Loading…
Reference in New Issue