From 458a35cf09dc4d41a6b47b28d6bce9baac579f8c Mon Sep 17 00:00:00 2001 From: goodboy Date: Thu, 23 Apr 2026 18:17:56 -0400 Subject: [PATCH] Surface silent failures in `_subint_forkserver` MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Three places that previously swallowed exceptions silently now log via `log.exception()` so they surface in the runtime log when something weird happens — easier to track down sneaky failures in the fork-from-worker-thread / subint-bootstrap primitives. Deats, - `_close_inherited_fds()`: post-fork child's per-fd `os.close()` swallow now logs the fd that failed to close. The comment notes the expected failure modes (already-closed-via-listdir-race, otherwise-unclosable) — both still fine to ignore semantically, but worth flagging in the log. - `fork_from_worker_thread()` parent-side timeout branch: the `os.close(rfd)` + `os.close(wfd)` cleanup now logs each pipe-fd close failure separately before raising the `worker thread didn't return` RuntimeError. - `run_subint_in_worker_thread._drive()`: when `_interpreters.exec(interp_id, bootstrap)` raises a `BaseException`, log the full call signature (interp_id + bootstrap) along with the captured exception, before stashing into `err` for the outer caller. Behavior unchanged — only adds observability. (this commit msg was generated in some part by [`claude-code`][claude-code-gh]) [claude-code-gh]: https://github.com/anthropics/claude-code --- tractor/spawn/_subint_forkserver.py | 27 ++++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-) diff --git a/tractor/spawn/_subint_forkserver.py b/tractor/spawn/_subint_forkserver.py index f29474e2..f8431ed3 100644 --- a/tractor/spawn/_subint_forkserver.py +++ b/tractor/spawn/_subint_forkserver.py @@ -252,9 +252,13 @@ def _close_inherited_fds( os.close(fd) closed += 1 except OSError: - # fd was already closed (race with listdir) or - # otherwise unclosable — either is fine. - pass + # fd was already closed (race with listdir) or otherwise + # unclosable — either is fine. + log.exception( + f'Failed to close inherited fd in child ??\n' + f'{fd!r}\n' + ) + return closed @@ -401,11 +405,17 @@ def fork_from_worker_thread( try: os.close(rfd) except OSError: - pass + log.exception( + f'Failed to close PID-pipe read-fd in parent ??\n' + f'{rfd!r}\n' + ) try: os.close(wfd) except OSError: - pass + log.exception( + f'Failed to close PID-pipe write-fd in parent ??\n' + f'{wfd!r}\n' + ) raise RuntimeError( f'subint-forkserver worker thread ' f'{thread_name!r} did not return within ' @@ -475,6 +485,13 @@ def run_subint_in_worker_thread( _interpreters.exec(interp_id, bootstrap) except BaseException as e: err = e + log.exception( + f'Failed to .exec() in subint ??\n' + f'_interpreters.exec(\n' + f' interp_id={interp_id!r},\n' + f' bootstrap={bootstrap!r},\n' + f') => {err!r}\n' + ) worker: threading.Thread = threading.Thread( target=_drive,