Adjust `._runtime` to report `DebugStatus.req_ctx`
- inside the `Actor.cancel()`'s maybe-wait-on-debugger delay, report the full debug request status and it's affiliated lock request IPC ctx. - use the new `.req_ctx.chan.uid` to do the local nursery lookup during channel teardown handling. - another couple log fmt tweaks.runtime_to_msgspec
parent
c929bc15c9
commit
f85314ecab
|
@ -644,7 +644,7 @@ class Actor:
|
||||||
peers_str: str = ''
|
peers_str: str = ''
|
||||||
for uid, chans in self._peers.items():
|
for uid, chans in self._peers.items():
|
||||||
peers_str += (
|
peers_str += (
|
||||||
f'|_ uid: {uid}\n'
|
f'uid: {uid}\n'
|
||||||
)
|
)
|
||||||
for i, chan in enumerate(chans):
|
for i, chan in enumerate(chans):
|
||||||
peers_str += (
|
peers_str += (
|
||||||
|
@ -678,10 +678,12 @@ class Actor:
|
||||||
# XXX => YES IT DOES, when i was testing ctl-c
|
# XXX => YES IT DOES, when i was testing ctl-c
|
||||||
# from broken debug TTY locking due to
|
# from broken debug TTY locking due to
|
||||||
# msg-spec races on application using RunVar...
|
# msg-spec races on application using RunVar...
|
||||||
pdb_user_uid: tuple = pdb_lock.global_actor_in_debug
|
|
||||||
if (
|
if (
|
||||||
pdb_user_uid
|
(ctx_in_debug := pdb_lock.ctx_in_debug)
|
||||||
and local_nursery
|
and
|
||||||
|
(pdb_user_uid := ctx_in_debug.chan.uid)
|
||||||
|
and
|
||||||
|
local_nursery
|
||||||
):
|
):
|
||||||
entry: tuple|None = local_nursery._children.get(
|
entry: tuple|None = local_nursery._children.get(
|
||||||
tuple(pdb_user_uid)
|
tuple(pdb_user_uid)
|
||||||
|
@ -1169,13 +1171,17 @@ class Actor:
|
||||||
|
|
||||||
# kill any debugger request task to avoid deadlock
|
# kill any debugger request task to avoid deadlock
|
||||||
# with the root actor in this tree
|
# with the root actor in this tree
|
||||||
dbcs = _debug.DebugStatus.req_cs
|
debug_req = _debug.DebugStatus
|
||||||
if dbcs is not None:
|
lock_req_ctx: Context = debug_req.req_ctx
|
||||||
|
if lock_req_ctx is not None:
|
||||||
msg += (
|
msg += (
|
||||||
'-> Cancelling active debugger request..\n'
|
'-> Cancelling active debugger request..\n'
|
||||||
f'|_{_debug.Lock.pformat()}'
|
f'|_{_debug.Lock.repr()}\n\n'
|
||||||
|
f'|_{lock_req_ctx}\n\n'
|
||||||
)
|
)
|
||||||
dbcs.cancel()
|
# lock_req_ctx._scope.cancel()
|
||||||
|
# TODO: wrap this in a method-API..
|
||||||
|
debug_req.req_cs.cancel()
|
||||||
|
|
||||||
# self-cancel **all** ongoing RPC tasks
|
# self-cancel **all** ongoing RPC tasks
|
||||||
await self.cancel_rpc_tasks(
|
await self.cancel_rpc_tasks(
|
||||||
|
@ -1375,15 +1381,17 @@ class Actor:
|
||||||
"IPC channel's "
|
"IPC channel's "
|
||||||
)
|
)
|
||||||
rent_chan_repr: str = (
|
rent_chan_repr: str = (
|
||||||
f'|_{parent_chan}'
|
f' |_{parent_chan}\n\n'
|
||||||
if parent_chan
|
if parent_chan
|
||||||
else ''
|
else ''
|
||||||
)
|
)
|
||||||
log.cancel(
|
log.cancel(
|
||||||
f'Cancelling {descr} {len(tasks)} rpc tasks\n\n'
|
f'Cancelling {descr} RPC tasks\n\n'
|
||||||
f'<= `Actor.cancel_rpc_tasks()`: {req_uid}\n'
|
f'<= canceller: {req_uid}\n'
|
||||||
f' {rent_chan_repr}\n'
|
f'{rent_chan_repr}'
|
||||||
# f'{self}\n'
|
f'=> cancellee: {self.uid}\n'
|
||||||
|
f' |_{self}.cancel_rpc_tasks()\n'
|
||||||
|
f' |_tasks: {len(tasks)}\n'
|
||||||
# f'{tasks_str}'
|
# f'{tasks_str}'
|
||||||
)
|
)
|
||||||
for (
|
for (
|
||||||
|
@ -1413,7 +1421,7 @@ class Actor:
|
||||||
if tasks:
|
if tasks:
|
||||||
log.cancel(
|
log.cancel(
|
||||||
'Waiting for remaining rpc tasks to complete\n'
|
'Waiting for remaining rpc tasks to complete\n'
|
||||||
f'|_{tasks}'
|
f'|_{tasks_str}'
|
||||||
)
|
)
|
||||||
await self._ongoing_rpc_tasks.wait()
|
await self._ongoing_rpc_tasks.wait()
|
||||||
|
|
||||||
|
@ -1466,7 +1474,10 @@ class Actor:
|
||||||
assert self._parent_chan, "No parent channel for this actor?"
|
assert self._parent_chan, "No parent channel for this actor?"
|
||||||
return Portal(self._parent_chan)
|
return Portal(self._parent_chan)
|
||||||
|
|
||||||
def get_chans(self, uid: tuple[str, str]) -> list[Channel]:
|
def get_chans(
|
||||||
|
self,
|
||||||
|
uid: tuple[str, str],
|
||||||
|
) -> list[Channel]:
|
||||||
'''
|
'''
|
||||||
Return all IPC channels to the actor with provided `uid`.
|
Return all IPC channels to the actor with provided `uid`.
|
||||||
|
|
||||||
|
@ -1626,7 +1637,9 @@ async def async_main(
|
||||||
# tranport address bind errors - normally it's
|
# tranport address bind errors - normally it's
|
||||||
# something silly like the wrong socket-address
|
# something silly like the wrong socket-address
|
||||||
# passed via a config or CLI Bo
|
# passed via a config or CLI Bo
|
||||||
entered_debug = await _debug._maybe_enter_pm(oserr)
|
entered_debug = await _debug._maybe_enter_pm(
|
||||||
|
oserr,
|
||||||
|
)
|
||||||
if entered_debug:
|
if entered_debug:
|
||||||
log.runtime('Exited debug REPL..')
|
log.runtime('Exited debug REPL..')
|
||||||
raise
|
raise
|
||||||
|
|
Loading…
Reference in New Issue