forked from goodboy/tractor
Use `Context` repr APIs for RPC outcome logs
Delegate to the new `.repr_state: str` and adjust log level based on error vs. cancel vs. result.runtime_to_msgspec
parent
4a270f85ca
commit
21f633a900
|
@ -739,37 +739,24 @@ async def _invoke(
|
||||||
cid,
|
cid,
|
||||||
))
|
))
|
||||||
|
|
||||||
|
logmeth: Callable = log.runtime
|
||||||
merr: Exception|None = ctx.maybe_error
|
merr: Exception|None = ctx.maybe_error
|
||||||
(
|
descr_str: str = 'with final result `{repr(ctx.outcome)}`'
|
||||||
res_type_str,
|
|
||||||
res_str,
|
|
||||||
) = (
|
|
||||||
('error', f'{type(merr)}',) if merr
|
|
||||||
else (
|
|
||||||
'result',
|
|
||||||
f'`{repr(ctx.outcome)}`',
|
|
||||||
)
|
|
||||||
)
|
|
||||||
message: str = (
|
message: str = (
|
||||||
f'IPC context terminated with a final {res_type_str}\n\n'
|
f'IPC context terminated {descr_str}\n\n'
|
||||||
f'{ctx}'
|
|
||||||
)
|
)
|
||||||
if merr:
|
if merr:
|
||||||
from tractor import RemoteActorError
|
descr_str: str = (
|
||||||
if not isinstance(merr, RemoteActorError):
|
f'with ctx having {ctx.repr_state!r}\n'
|
||||||
fmt_merr: str = (
|
f'{ctx.repr_outcome()}\n'
|
||||||
f'\n{merr!r}\n'
|
|
||||||
# f'{merr.args[0]!r}\n'
|
|
||||||
)
|
|
||||||
else:
|
|
||||||
fmt_merr = f'\n{merr!r}'
|
|
||||||
log.error(
|
|
||||||
message
|
|
||||||
+
|
|
||||||
fmt_merr
|
|
||||||
)
|
)
|
||||||
else:
|
if isinstance(merr, ContextCancelled):
|
||||||
log.runtime(message)
|
logmeth: Callable = log.runtime
|
||||||
|
else:
|
||||||
|
logmeth: Callable = log.error
|
||||||
|
message += f'\n{merr!r}\n'
|
||||||
|
|
||||||
|
logmeth(message)
|
||||||
|
|
||||||
|
|
||||||
async def try_ship_error_to_remote(
|
async def try_ship_error_to_remote(
|
||||||
|
|
Loading…
Reference in New Issue