From 5f8f8e98ba62be422e1ae42c6c482d63aa02efd9 Mon Sep 17 00:00:00 2001 From: Tyler Goodlet Date: Thu, 4 Jul 2024 15:06:15 -0400 Subject: [PATCH] More-n-more scops annots in logging --- tractor/_context.py | 11 ++++++---- tractor/_entry.py | 1 + tractor/_portal.py | 6 +++--- tractor/_runtime.py | 50 ++++++++++++++++++++++++++++----------------- 4 files changed, 42 insertions(+), 26 deletions(-) diff --git a/tractor/_context.py b/tractor/_context.py index cc6503e..ff44a34 100644 --- a/tractor/_context.py +++ b/tractor/_context.py @@ -2376,8 +2376,9 @@ async def open_context_from_portal( and ctx.cancel_acked ): log.cancel( - f'Context cancelled by {ctx.side!r}-side task\n' - f'|_{ctx._task}\n\n' + f'Context cancelled by local {ctx.side!r}-side task\n' + f'c)>\n' + f' |_{ctx._task}\n\n' f'{repr(scope_err)}\n' ) @@ -2393,8 +2394,10 @@ async def open_context_from_portal( # type_only=True, ) log.cancel( - f'Context terminated due to local {ctx.side!r}-side error:\n\n' - f'{ctx.chan.uid} => {outcome_str}\n' + f'Context terminated due to {ctx.side!r}-side\n\n' + # TODO: do an x)> on err and c)> only for ctxc? + f'c)> {outcome_str}\n' + f' |_{ctx.repr_rpc}\n' ) # FINALLY, remove the context from runtime tracking and diff --git a/tractor/_entry.py b/tractor/_entry.py index 3f17452..a072706 100644 --- a/tractor/_entry.py +++ b/tractor/_entry.py @@ -243,6 +243,7 @@ def _trio_main( nest_from_op( input_op=')>', # like a "closed-to-play"-icon from super perspective tree_str=actor_info, + back_from_op=1, ) ) try: diff --git a/tractor/_portal.py b/tractor/_portal.py index 3dc7f3a..f5a6683 100644 --- a/tractor/_portal.py +++ b/tractor/_portal.py @@ -263,11 +263,11 @@ class Portal: return False reminfo: str = ( - f'Portal.cancel_actor() => {self.channel.uid}\n' - f'|_{chan}\n' + f'c)=> {self.channel.uid}\n' + f' |_{chan}\n' ) log.cancel( - f'Requesting runtime cancel for peer\n\n' + f'Requesting actor-runtime cancel for peer\n\n' f'{reminfo}' ) diff --git a/tractor/_runtime.py b/tractor/_runtime.py index 92afa29..f946cb1 100644 --- a/tractor/_runtime.py +++ b/tractor/_runtime.py @@ -439,10 +439,10 @@ class Actor: TransportClosed, ): - # XXX: This may propagate up from ``Channel._aiter_recv()`` - # and ``MsgpackStream._inter_packets()`` on a read from the + # XXX: This may propagate up from `Channel._aiter_recv()` + # and `MsgpackStream._inter_packets()` on a read from the # stream particularly when the runtime is first starting up - # inside ``open_root_actor()`` where there is a check for + # inside `open_root_actor()` where there is a check for # a bound listener on the "arbiter" addr. the reset will be # because the handshake was never meant took place. log.runtime( @@ -507,8 +507,9 @@ class Actor: ) except trio.Cancelled: log.cancel( - 'IPC transport msg loop was cancelled for \n' - f'|_{chan}\n' + 'IPC transport msg loop was cancelled\n' + f'c)>\n' + f' |_{chan}\n' ) raise @@ -545,9 +546,9 @@ class Actor: ): log.cancel( - 'Waiting on cancel request to peer\n' + 'Waiting on cancel request to peer..\n' f'c)=>\n' - f' |_{chan.uid}\n' + f' |_{chan.uid}\n' ) # XXX: this is a soft wait on the channel (and its @@ -646,10 +647,14 @@ class Actor: ): report: str = ( 'Timed out waiting on local actor-nursery to exit?\n' - f'{local_nursery}\n' + f'c)>\n' + f' |_{local_nursery}\n' ) if children := local_nursery._children: - report += f' |_{pformat(children)}\n' + # indent from above local-nurse repr + report += ( + f' |_{pformat(children)}\n' + ) log.warning(report) @@ -1236,8 +1241,9 @@ class Actor: # TODO: just use the new `Context.repr_rpc: str` (and # other) repr fields instead of doing this all manual.. msg: str = ( - f'Runtime cancel request from {requester_type}:\n\n' - f'<= .cancel(): {requesting_uid}\n\n' + f'Actor-runtime cancel request from {requester_type}\n\n' + f'<=c) {requesting_uid}\n' + f' |_{self}\n' ) # TODO: what happens here when we self-cancel tho? @@ -1347,7 +1353,7 @@ class Actor: log.cancel( 'Rxed cancel request for RPC task\n' f'<=c) {requesting_uid}\n' - f' |_{ctx._task}\n' + f' |_{ctx._task}\n' f' >> {ctx.repr_rpc}\n' # f'=> {ctx._task}\n' # f' >> Actor._cancel_task() => {ctx._task}\n' @@ -1465,17 +1471,17 @@ class Actor: "IPC channel's " ) rent_chan_repr: str = ( - f' |_{parent_chan}\n\n' + f' |_{parent_chan}\n\n' if parent_chan else '' ) log.cancel( f'Cancelling {descr} RPC tasks\n\n' - f'<= canceller: {req_uid}\n' + f'<=c) {req_uid} [canceller]\n' f'{rent_chan_repr}' - f'=> cancellee: {self.uid}\n' - f' |_{self}.cancel_rpc_tasks()\n' - f' |_tasks: {len(tasks)}\n' + f'c)=> {self.uid} [cancellee]\n' + f' |_{self} [with {len(tasks)} tasks]\n' + # f' |_tasks: {len(tasks)}\n' # f'{tasks_str}' ) for ( @@ -1932,9 +1938,15 @@ async def async_main( with CancelScope(shield=True): await actor._no_more_peers.wait() - teardown_report += ('-> All peer channels are complete\n') + teardown_report += ( + '-> All peer channels are complete\n' + ) - teardown_report += ('Actor runtime exited') + teardown_report += ( + 'Actor runtime exiting\n' + f'>)\n' + f'|_{actor}\n' + ) log.info(teardown_report)