Repository navigation
Bound ai-accounts stderr drain after the command exits #1721
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -95,6 +95,12 @@ def test_codex_requires_requested_model_evidence(helper, monkeypatch): | |
| assert helper.active('codex') == 'main' | ||
|
|
||
|
|
||
| def test_run_returns_after_leader_exits_with_inherited_stderr(helper): | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. suggestion: No test checks that partial stderr blocks replay The new test only checks that the wrapper returns exit code 7 when nothing would trigger replay. Nothing checks the third acceptance item: when the drain times out after a retryable exit whose partial stderr already matches |
||
| argv = [helper.sys.executable, helper.__file__, 'run', 'claude', '--', helper.sys.executable, | ||
| '-c', 'import subprocess, sys; subprocess.Popen(["sleep", "6"]); sys.exit(7)'] | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. suggestion: The test leaves a The grandchild |
||
| assert helper.subprocess.run(argv, timeout=5).returncode == 7 | ||
|
|
||
|
|
||
| @pytest.mark.parametrize('providers,explicit,retry_safe,runs,active', [ | ||
| ('claude,codex', False, False, 1, 'a'), ('claude', False, False, 1, 'b'), | ||
| ('claude', False, True, 2, 'b'), ('claude', True, True, 1, 'a')]) | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggestion: A daemon pump still writing at shutdown can abort the interpreter and replace the leader's exit code
When the drain times out,
cmd_runreturns andsys.exitstarts interpreter finalization while the daemonpumpthread is still running. If a lingering descendant keeps writing stderr and the pump is blocked insidesys.stderr.buffer.write(for example because whoever reads the wrapper's stderr has stalled), it holds the BufferedWriter lock. During finalization,flush_std_fileswaits about 1s for that lock and then callsPy_FatalError("could not acquire lock for <stderr> at interpreter shutdown, possibly due to daemon threads"). The process then exits from SIGABRT (status 134) instead of returning the leader's code. That breaks the 'exit status is preserved' acceptance criterion in the same scenario this change targets. This only happens when the stderr consumer stalls, so the window is narrow. Smallest fix: havepumpwrite withos.write(2, chunk)instead of the bufferedsys.stderr.buffer, so the daemon never holds an interpreter-level I/O lock. Alternatively, callsys.stderr.flush()thenos._exit(code)on the timed-out path.