From 5b2905b70212dd8e6db2083b9b987cc9516f79ef Mon Sep 17 00:00:00 2001 From: goodboy Date: Tue, 3 Mar 2026 13:47:04 -0500 Subject: [PATCH] Xplatform tweaks for `daemon` fixture There's a very sloppy registrar-actor-bootup syncing approach used in this fixture (basically just guessing how long to sleep to wait for it to init and bind the registry socket) using a `global _PROC_SPAWN_WAIT` that needs to be made more reliable. But, for now i'm just playing along with what's there to try and make less CI runs flaky by, - sleeping *another* 1s when run from non-linux CI. - reporting stdout (if any) alongside stderr on teardown. - not strictly requiring a `proc.returncode == -2` indicating successful graceful cancellation via SIGINT; instead we now error-log and only raise the RTE on `< 0` exit code. * though i can't think of why this would happen other then an underlying crash which should propagate.. but i don't think any test suite does this intentionally rn? * though i don't think it should ever happen, having a CI run "error"-fail bc of this isn't all that illuminating, if there is some weird `.returncode == 0` termination case it's likely not a failure? For later, see the new todo list; we should sync to some kind of "ping" polling of the tpt address if possible which is already easy enough for TCP reusing an internal closure from `._root.open_root_actor()`. --- tests/conftest.py | 47 ++++++++++++++++++++++++++++++++--------------- 1 file changed, 32 insertions(+), 15 deletions(-) diff --git a/tests/conftest.py b/tests/conftest.py index 09602c96..31787fe2 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -189,41 +189,58 @@ def daemon( **kwargs, ) + # TODO! we should poll for the registry socket-bind to take place + # and only once that's done yield to the requester! + # -[ ] TCP: use the `._root.open_root_actor()`::`ping_tpt_socket()` + # closure! + # -[ ] UDS: can we do something similar for 'pinging" the + # file-socket? + # + global _PROC_SPAWN_WAIT # UDS sockets are **really** fast to bind()/listen()/connect() # so it's often required that we delay a bit more starting # the first actor-tree.. if tpt_proto == 'uds': - global _PROC_SPAWN_WAIT _PROC_SPAWN_WAIT = 0.6 + if _non_linux and ci_env: + _PROC_SPAWN_WAIT += 1 + + # XXX, allow time for the sub-py-proc to boot up. + # !TODO, see ping-polling ideas above! time.sleep(_PROC_SPAWN_WAIT) assert not proc.returncode - # TODO! we should poll for the registry socket-bind to take place - # and only once that's done yield to the requester! - # -[ ] use the `._root.open_root_actor()`::`ping_tpt_socket()` - # closure! - if _non_linux and ci_env: - time.sleep(1) - yield proc sig_prog(proc, _INT_SIGNAL) # XXX! yeah.. just be reaaal careful with this bc sometimes it # can lock up on the `_io.BufferedReader` and hang.. stderr: str = proc.stderr.read().decode() - if stderr: + stdout: str = proc.stdout.read().decode() + if ( + stderr + or + stdout + ): print( - f'Daemon actor tree produced STDERR:\n' + f'Daemon actor tree produced output:\n' f'{proc.args}\n' f'\n' - f'{stderr}\n' + f'stderr: {stderr!r}\n' + f'stdout: {stdout!r}\n' ) - if proc.returncode != -2: - raise RuntimeError( - 'Daemon actor tree failed !?\n' - f'{proc.args}\n' + + if (rc := proc.returncode) != -2: + msg: str = ( + f'Daemon actor tree was not cancelled !?\n' + f'proc.args: {proc.args!r}\n' + f'proc.returncode: {rc!r}\n' ) + if rc < 0: + raise RuntimeError(msg) + + log.error(msg) # @pytest.fixture(autouse=True)