More `.ipc.Channel`-repr related tweaks
- only generate a repr in `.from_addr()` when log level is >= 'runtime'. |_ add a todo about supporting this optimization more generally on our adapter. - fix `Channel.pformat()` to show unknown peer field line fmt correctly. - add a `Channel.maddr: str` which just delegates directly to the `._transport` like other pass-thru property fields.enable_tpts
parent
a9da16892d
commit
3201437f4e
|
@ -171,11 +171,23 @@ class Channel:
|
|||
)
|
||||
assert transport.raddr == addr
|
||||
chan = Channel(transport=transport)
|
||||
log.runtime(
|
||||
f'Connected channel IPC transport\n'
|
||||
f'[>\n'
|
||||
f' |_{chan}\n'
|
||||
)
|
||||
|
||||
# ?TODO, compact this into adapter level-methods?
|
||||
# -[ ] would avoid extra repr-calcs if level not active?
|
||||
# |_ how would the `calc_if_level` look though? func?
|
||||
if log.at_least_level('runtime'):
|
||||
from tractor.devx import (
|
||||
pformat as _pformat,
|
||||
)
|
||||
chan_repr: str = _pformat.nest_from_op(
|
||||
input_op='[>',
|
||||
text=chan.pformat(),
|
||||
nest_indent=1,
|
||||
)
|
||||
log.runtime(
|
||||
f'Connected channel IPC transport\n'
|
||||
f'{chan_repr}'
|
||||
)
|
||||
return chan
|
||||
|
||||
@cm
|
||||
|
@ -218,7 +230,7 @@ class Channel:
|
|||
if privates else ''
|
||||
) + ( # peer-actor (processs) section
|
||||
f' |_peer: {self.aid.reprol()!r}\n'
|
||||
if self.aid else '<unknown>'
|
||||
if self.aid else ' |_peer: <unknown>\n'
|
||||
) + (
|
||||
f' |_msgstream: {tpt_name}\n'
|
||||
f' maddr: {tpt.maddr!r}\n'
|
||||
|
@ -259,6 +271,10 @@ class Channel:
|
|||
def raddr(self) -> Address|None:
|
||||
return self._transport.raddr if self._transport else None
|
||||
|
||||
@property
|
||||
def maddr(self) -> str:
|
||||
return self._transport.maddr if self._transport else '<no-tpt>'
|
||||
|
||||
# TODO: something like,
|
||||
# `pdbp.hideframe_on(errors=[MsgTypeError])`
|
||||
# instead of the `try/except` hack we have rn..
|
||||
|
|
Loading…
Reference in New Issue