Fix `.boxed_type` facepalm, drop `.src_actor_uid`
The misname of `._boxed_type` as `._src_type` was only manifesting as a reallly strange boxing error with a packed exception-group, not sure how or why only that but it's fixed now XD Start refining/cleaning out stuff for sure we don't need (based on multiple local test runs): - discard `.src_actor_uid` fully since test set has been moved over to `.src_uid`; this means also removing the `.msgdata` insertion from `pack_error()`; a patch to all internals is coming next obvi! - don't pass `boxed_type` to `RemoteActorError.__init__()` from `unpack_error()` since it's now set directly via the `.msgdata["boxed_type_str"]`/`error_msg: dict` input , but in the case where **it is passed as an arg** (only for ctxc in `._rpc._invoke()` rn) make sure we only do the `.__init__()` insert when `boxed_type is not None`.mv_to_new_trio_py3.11
parent
5fb5682269
commit
78434f6317
|
@ -109,7 +109,6 @@ class RemoteActorError(Exception):
|
||||||
|
|
||||||
'''
|
'''
|
||||||
reprol_fields: list[str] = [
|
reprol_fields: list[str] = [
|
||||||
# 'src_actor_uid',
|
|
||||||
'src_uid',
|
'src_uid',
|
||||||
'relay_path',
|
'relay_path',
|
||||||
# 'relay_uid',
|
# 'relay_uid',
|
||||||
|
@ -143,9 +142,6 @@ class RemoteActorError(Exception):
|
||||||
# pre-`return` lines?
|
# pre-`return` lines?
|
||||||
# sanity on inceptions
|
# sanity on inceptions
|
||||||
if boxed_type is RemoteActorError:
|
if boxed_type is RemoteActorError:
|
||||||
if self.src_type_str == 'RemoteActorError':
|
|
||||||
import pdbp; pdbp.set_trace()
|
|
||||||
|
|
||||||
assert self.src_type_str != 'RemoteActorError'
|
assert self.src_type_str != 'RemoteActorError'
|
||||||
assert self.src_uid not in self.relay_path
|
assert self.src_uid not in self.relay_path
|
||||||
|
|
||||||
|
@ -158,7 +154,7 @@ class RemoteActorError(Exception):
|
||||||
# should better emphasize that special (one off?) case
|
# should better emphasize that special (one off?) case
|
||||||
# either by customizing `ContextCancelled.__init__()` or
|
# either by customizing `ContextCancelled.__init__()` or
|
||||||
# through a special factor func?
|
# through a special factor func?
|
||||||
else:
|
elif boxed_type:
|
||||||
if not self.msgdata.get('boxed_type_str'):
|
if not self.msgdata.get('boxed_type_str'):
|
||||||
self.msgdata['boxed_type_str'] = str(
|
self.msgdata['boxed_type_str'] = str(
|
||||||
type(boxed_type).__name__
|
type(boxed_type).__name__
|
||||||
|
@ -206,7 +202,7 @@ class RemoteActorError(Exception):
|
||||||
|
|
||||||
'''
|
'''
|
||||||
if self._boxed_type is None:
|
if self._boxed_type is None:
|
||||||
self._src_type = get_err_type(
|
self._boxed_type = get_err_type(
|
||||||
self.msgdata['boxed_type_str']
|
self.msgdata['boxed_type_str']
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -235,9 +231,6 @@ class RemoteActorError(Exception):
|
||||||
def src_uid(self) -> tuple[str, str]|None:
|
def src_uid(self) -> tuple[str, str]|None:
|
||||||
if src_uid := (
|
if src_uid := (
|
||||||
self.msgdata.get('src_uid')
|
self.msgdata.get('src_uid')
|
||||||
# TODO: remove!
|
|
||||||
or
|
|
||||||
self.msgdata.get('src_actor_uid')
|
|
||||||
):
|
):
|
||||||
return tuple(src_uid)
|
return tuple(src_uid)
|
||||||
# TODO: use path lookup instead?
|
# TODO: use path lookup instead?
|
||||||
|
@ -245,12 +238,6 @@ class RemoteActorError(Exception):
|
||||||
# self.msgdata['relay_path'][0]
|
# self.msgdata['relay_path'][0]
|
||||||
# )
|
# )
|
||||||
|
|
||||||
# TODO: deprecate this for ^!
|
|
||||||
@property
|
|
||||||
def src_actor_uid(self) -> tuple[str, str]|None:
|
|
||||||
log.warning('.src_actor_uid` is deprecated, use `.src_uid` instead!')
|
|
||||||
return self.src_uid
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def tb_str(
|
def tb_str(
|
||||||
self,
|
self,
|
||||||
|
@ -517,7 +504,8 @@ def pack_error(
|
||||||
# an onion/inception we need to pack
|
# an onion/inception we need to pack
|
||||||
if (
|
if (
|
||||||
type(exc) is RemoteActorError
|
type(exc) is RemoteActorError
|
||||||
and exc.boxed_type != RemoteActorError
|
and (boxed := exc.boxed_type)
|
||||||
|
and boxed != RemoteActorError
|
||||||
):
|
):
|
||||||
# sanity on source error (if needed when tweaking this)
|
# sanity on source error (if needed when tweaking this)
|
||||||
assert (src_type := exc.src_type) != RemoteActorError
|
assert (src_type := exc.src_type) != RemoteActorError
|
||||||
|
@ -536,13 +524,6 @@ def pack_error(
|
||||||
# the input `exc` type.
|
# the input `exc` type.
|
||||||
error_msg['boxed_type_str'] = 'RemoteActorError'
|
error_msg['boxed_type_str'] = 'RemoteActorError'
|
||||||
|
|
||||||
# import pdbp; pdbp.set_trace()
|
|
||||||
# log.debug(
|
|
||||||
# 'INCEPTION packing!\n\n'
|
|
||||||
# f'{pformat(exc.msgdata)}\n\n'
|
|
||||||
# f'{exc}\n'
|
|
||||||
# )
|
|
||||||
|
|
||||||
else:
|
else:
|
||||||
error_msg['src_uid'] = our_uid
|
error_msg['src_uid'] = our_uid
|
||||||
error_msg['src_type_str'] = type(exc).__name__
|
error_msg['src_type_str'] = type(exc).__name__
|
||||||
|
@ -566,6 +547,7 @@ def unpack_error(
|
||||||
|
|
||||||
chan: Channel|None = None,
|
chan: Channel|None = None,
|
||||||
box_type: RemoteActorError = RemoteActorError,
|
box_type: RemoteActorError = RemoteActorError,
|
||||||
|
|
||||||
hide_tb: bool = True,
|
hide_tb: bool = True,
|
||||||
|
|
||||||
) -> None|Exception:
|
) -> None|Exception:
|
||||||
|
@ -593,15 +575,15 @@ def unpack_error(
|
||||||
+
|
+
|
||||||
tb_str
|
tb_str
|
||||||
)
|
)
|
||||||
boxed_type_str: str = (
|
|
||||||
# TODO: deprecate this!
|
# try to lookup a suitable error type from the local runtime
|
||||||
error_dict.get('boxed_type_str')
|
# env then use it to construct a local instance.
|
||||||
# or error_dict['boxed_type']
|
boxed_type_str: str = error_dict['boxed_type_str']
|
||||||
)
|
boxed_type: Type[BaseException] = get_err_type(boxed_type_str)
|
||||||
boxed_type: Type[BaseException] = Exception
|
|
||||||
|
|
||||||
if boxed_type_str == 'ContextCancelled':
|
if boxed_type_str == 'ContextCancelled':
|
||||||
boxed_type = box_type = ContextCancelled
|
box_type = ContextCancelled
|
||||||
|
assert boxed_type is box_type
|
||||||
|
|
||||||
# TODO: already included by `_this_mod` in else loop right?
|
# TODO: already included by `_this_mod` in else loop right?
|
||||||
#
|
#
|
||||||
|
@ -609,19 +591,11 @@ def unpack_error(
|
||||||
# we include the relay_path info and the
|
# we include the relay_path info and the
|
||||||
# original source error.
|
# original source error.
|
||||||
elif boxed_type_str == 'RemoteActorError':
|
elif boxed_type_str == 'RemoteActorError':
|
||||||
boxed_type = RemoteActorError
|
assert boxed_type is RemoteActorError
|
||||||
assert len(error_dict['relay_path']) >= 1
|
assert len(error_dict['relay_path']) >= 1
|
||||||
|
|
||||||
# try to lookup a suitable error type
|
|
||||||
# from the local runtime env.
|
|
||||||
else:
|
|
||||||
boxed_type = get_err_type(boxed_type_str)
|
|
||||||
|
|
||||||
exc = box_type(
|
exc = box_type(
|
||||||
message,
|
message,
|
||||||
boxed_type=boxed_type,
|
|
||||||
|
|
||||||
# unpack other fields into error type init
|
|
||||||
**error_dict,
|
**error_dict,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue