-
Notifications
You must be signed in to change notification settings - Fork 37
Timeouts #325
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
Merged
Merged
Timeouts #325
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Use shlex.quote() instead of Python repr for proper shell escaping when wrapping commands with timeout. This fixes syntax errors when commands contain special characters like parentheses (e.g., in git apply patches). Also update test_eval_timeout to expect the new timeout message format. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- DockerTerminal.close(): Close docker_client to release connection pool resources. Previously only the container was stopped but the client connection was never closed, causing pool exhaustion after ~10 iterations. - ShellSession.close(): Add process.wait() after terminate() to avoid zombie processes. If wait times out, forcefully kill the process. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
The previous fix closed the Docker client in close() to prevent connection leaks, but setting docker_client = None broke terminal reuse since setup_container() would fail with 'NoneType' has no attribute 'containers'. This fix converts docker_client to a lazy-initialized property that recreates the client on demand if it was previously closed. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
The close() method was only stopping the listener thread but not closing FileHandler instances, leaving file handles open. This caused processes to hang indefinitely when many loggers were created (e.g., per-agent loggers in parallel evaluation). 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
MarcCote
approved these changes
Jan 7, 2026
xingdi-eric-yuan
added a commit
that referenced
this pull request
Jan 8, 2026
When nohup commands with background execution (&) are run through the timeout wrapper in Docker/Kubernetes terminals, the timeout command doesn't return immediately because background processes inherit the shell's stdout/stderr file descriptors. This fix adds proper output redirection (> /dev/null 2>&1) to the gunicorn nohup commands in SWE-Bench setup, ensuring the timeout wrapper returns immediately after the shell exits instead of waiting for the full timeout period. Also adds comprehensive tests for both Docker and Kubernetes terminals to verify nohup commands with proper redirection return immediately. Fixes issue reported in #325 where requests package setup would hang for 300 seconds when starting background gunicorn servers. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
MarcCote
added a commit
that referenced
this pull request
Jan 9, 2026
* Fix nohup commands not returning immediately with timeout wrapper When nohup commands with background execution (&) are run through the timeout wrapper in Docker/Kubernetes terminals, the timeout command doesn't return immediately because background processes inherit the shell's stdout/stderr file descriptors. This fix adds proper output redirection (> /dev/null 2>&1) to the gunicorn nohup commands in SWE-Bench setup, ensuring the timeout wrapper returns immediately after the shell exits instead of waiting for the full timeout period. Also adds comprehensive tests for both Docker and Kubernetes terminals to verify nohup commands with proper redirection return immediately. Fixes issue reported in #325 where requests package setup would hang for 300 seconds when starting background gunicorn servers. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com> * Use setsid to properly detach background processes in non-TTY mode The previous fix using only output redirection was insufficient because in non-TTY mode, the timeout command monitors the entire process group, not just file descriptors. Even with > /dev/null 2>&1, backgrounded processes remain in the same process group as the shell. Using setsid creates a new session, completely detaching the process from timeout's process group. This ensures the timeout-wrapped command returns immediately after the shell exits, even in non-TTY execution contexts like docker exec and kubectl exec. Changes: - Added setsid before nohup gunicorn commands - Updated test names and documentation to reflect setsid usage - Tests verify processes detach properly in non-TTY mode Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com> * minor * nested shell * subshell * Run eval (if available) before applying the gold patch in the solution agent. --------- Co-authored-by: Claude Sonnet 4.5 <noreply@anthropic.com> Co-authored-by: Marc-Alexandre Côté <marc.cote.19@gmail.com>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR adds timeout handling to prevent agents from hanging:
E.g.,
Also:
Fix Docker client and shell process resource leaks
DockerTerminal.close(): Close docker_client to release connection pool
resources. Previously only the container was stopped but the client
connection was never closed, causing pool exhaustion after ~10 iterations.
ShellSession.close(): Add process.wait() after terminate() to avoid
zombie processes. If wait times out, forcefully kill the process.