diff --git a/tests/devx/conftest.py b/tests/devx/conftest.py index a516eecd..efc74d44 100644 --- a/tests/devx/conftest.py +++ b/tests/devx/conftest.py @@ -101,15 +101,18 @@ def spawn( start: float = time.time() timeout: float = 5 while ( - spawned + ptyproc.isalive() and - spawned.isalive() - and - (_time_took := (time.time() - start) < timeout) + ( + (_time_took := (time.time() - start)) + < + timeout + ) ): ptyproc.kill(signal.SIGINT) time.sleep(0.01) - else: + + if ptyproc.isalive(): ptyproc.kill(signal.SIGKILL) # TODO? ensure we've cleaned up any UDS-paths? diff --git a/tests/test_advanced_faults.py b/tests/test_advanced_faults.py index cfd9cd8b..2103f627 100644 --- a/tests/test_advanced_faults.py +++ b/tests/test_advanced_faults.py @@ -255,8 +255,10 @@ def test_ipc_channel_break_during_stream( assert ( len(excs) <= 2 and - (isinstance(exc, TransportClosed) - for exc in excs) + all( + isinstance(exc, TransportClosed) + for exc in excs + ) ) final_exc = excs[0] assert isinstance(final_exc, expect_final_exc) diff --git a/tractor/_rpc.py b/tractor/_rpc.py index bd26b5ed..e79bd8fc 100644 --- a/tractor/_rpc.py +++ b/tractor/_rpc.py @@ -284,9 +284,14 @@ async def _errors_relayed_via_ipc( try: yield # run RPC invoke body - except TransportClosed: - log.exception('Tpt disconnect during remote-exc relay?') - raise + # NOTE, never REPL any pseudo-expected tpt-disconnect. + except TransportClosed as err: + rpc_err = err + log.warning( + f'Tpt disconnect during remote-exc relay due to,\n' + f'{err!r}\n' + ) + raise err # box and ship RPC errors for wire-transit via # the task's requesting parent IPC-channel. @@ -323,9 +328,6 @@ async def _errors_relayed_via_ipc( and debug_kbis ) ) - # TODO? better then `debug_filter` below? - and - not isinstance(err, TransportClosed) ): # XXX QUESTION XXX: is there any case where we'll # want to debug IPC disconnects as a default? @@ -346,13 +348,6 @@ async def _errors_relayed_via_ipc( entered_debug = await debug._maybe_enter_pm( err, api_frame=inspect.currentframe(), - - # don't REPL any psuedo-expected tpt-disconnect - # debug_filter=lambda exc: ( - # type (exc) not in { - # TransportClosed, - # } - # ), ) if not entered_debug: # if we prolly should have entered the REPL but @@ -438,7 +433,7 @@ async def _errors_relayed_via_ipc( # cancel scope will not have been inserted yet if is_rpc: log.warning( - 'RPC task likely errored or cancelled before start?\n' + 'RPC task likely crashed or cancelled before start?\n' f'|_{ctx._task}\n' f' >> {ctx.repr_rpc}\n' ) @@ -694,22 +689,6 @@ async def _invoke( f'{pretty_struct.pformat(return_msg)}\n' ) await chan.send(return_msg) - # ?TODO, remove the below since .send() already - # doesn't raise on tpt-closed? - # try: - # await chan.send(return_msg) - # except TransportClosed: - # log.exception( - # f"Failed send final result to 'parent'-side of IPC-ctx!\n" - # f'\n' - # f'{chan}\n' - # f'Channel already disconnected ??\n' - # f'\n' - # f'{pretty_struct.pformat(return_msg)}' - # ) - # # ?TODO? will this ever be true though? - # if chan.connected(): - # raise # NOTE: this happens IFF `ctx._scope.cancel()` is # called by any of,