Surface silent failures in `_subint_forkserver`
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-codesubint_forkserver_backend
parent
7cd47ef7fb
commit
458a35cf09
|
|
@ -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,
|
||||
|
|
|
|||
Loading…
Reference in New Issue