From 8fa23fcccdbb04bda6dd215c342b73dd50bb0f55 Mon Sep 17 00:00:00 2001 From: Tyler Goodlet Date: Sat, 8 Mar 2025 15:50:14 -0500 Subject: [PATCH] Raise RTE from `limit_plds()` on no `curr_ctx` Since it should only be used from within a `Portal.open_context()` scope, make sure the caller knows that! Also don't hide the frame in tb if the immediate function errors.. --- tractor/msg/_ops.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/tractor/msg/_ops.py b/tractor/msg/_ops.py index 6f178ba..839be53 100644 --- a/tractor/msg/_ops.py +++ b/tractor/msg/_ops.py @@ -461,11 +461,16 @@ def limit_plds( ''' __tracebackhide__: bool = True + curr_ctx: Context|None = current_ipc_ctx() + if curr_ctx is None: + raise RuntimeError( + 'No IPC `Context` is active !?\n' + 'Did you open `limit_plds()` from outside ' + 'a `Portal.open_context()` scope-block?' + ) try: - curr_ctx: Context = current_ipc_ctx() rx: PldRx = curr_ctx._pld_rx orig_pldec: MsgDec = rx.pld_dec - with rx.limit_plds( spec=spec, **dec_kwargs, @@ -475,6 +480,11 @@ def limit_plds( f'{pldec}\n' ) yield pldec + + except BaseException: + __tracebackhide__: bool = False + raise + finally: log.runtime( 'Reverted to previous payload-decoder\n\n'