DRAFT: fix: disable posix_spawn on Python 3.13+ to fix libtmux race condition#1912
Draft
DRAFT: fix: disable posix_spawn on Python 3.13+ to fix libtmux race condition#1912
Conversation
Python 3.13 uses posix_spawn() more aggressively for subprocess calls, which can cause a race condition in libtmux where the list-sessions query runs before tmux has fully registered a newly created session. This workaround disables posix_spawn before importing libtmux to ensure reliable session creation in PyInstaller-bundled environments. See: https://docs.python.org/3/whatsnew/3.13.html#subprocess Fixes #1886 Co-authored-by: openhands <[email protected]>
Contributor
🔄 Running Examples with
|
| Example | Status | Duration | Cost |
|---|---|---|---|
| 01_standalone_sdk/02_custom_tools.py | ✅ PASS | 23.5s | $0.03 |
| 01_standalone_sdk/03_activate_skill.py | ✅ PASS | 16.2s | $0.03 |
| 01_standalone_sdk/05_use_llm_registry.py | ✅ PASS | 8.6s | $0.01 |
| 01_standalone_sdk/07_mcp_integration.py | ✅ PASS | 35.0s | $0.03 |
| 01_standalone_sdk/09_pause_example.py | ✅ PASS | 13.6s | $0.01 |
| 01_standalone_sdk/10_persistence.py | ✅ PASS | 26.2s | $0.02 |
| 01_standalone_sdk/11_async.py | ✅ PASS | 33.3s | $0.04 |
| 01_standalone_sdk/12_custom_secrets.py | ✅ PASS | 12.9s | $0.01 |
| 01_standalone_sdk/13_get_llm_metrics.py | ✅ PASS | 16.5s | $0.01 |
| 01_standalone_sdk/14_context_condenser.py | ✅ PASS | 3m 54s | $0.52 |
| 01_standalone_sdk/17_image_input.py | ✅ PASS | 14.4s | $0.02 |
| 01_standalone_sdk/18_send_message_while_processing.py | ✅ PASS | 23.0s | $0.01 |
| 01_standalone_sdk/19_llm_routing.py | ✅ PASS | 11.0s | $0.02 |
| 01_standalone_sdk/20_stuck_detector.py | ✅ PASS | 17.3s | $0.02 |
| 01_standalone_sdk/21_generate_extraneous_conversation_costs.py | ✅ PASS | 7.1s | $0.00 |
| 01_standalone_sdk/22_anthropic_thinking.py | ✅ PASS | 11.5s | $0.01 |
| 01_standalone_sdk/23_responses_reasoning.py | ✅ PASS | 1m 15s | $0.01 |
| 01_standalone_sdk/24_planning_agent_workflow.py | ✅ PASS | 3m 14s | $0.24 |
| 01_standalone_sdk/25_agent_delegation.py | ✅ PASS | 1m 38s | $0.15 |
| 01_standalone_sdk/26_custom_visualizer.py | ✅ PASS | 14.3s | $0.02 |
| 01_standalone_sdk/28_ask_agent_example.py | ❌ FAIL Exit code 1 |
33.6s | -- |
| 01_standalone_sdk/29_llm_streaming.py | ✅ PASS | 46.5s | $0.03 |
| 01_standalone_sdk/30_tom_agent.py | ❌ FAIL Exit code 1 |
2.3s | -- |
| 01_standalone_sdk/31_iterative_refinement.py | ✅ PASS | 3m 30s | $0.25 |
| 01_standalone_sdk/32_configurable_security_policy.py | ✅ PASS | 16.9s | $0.02 |
| 01_standalone_sdk/34_critic_example.py | ✅ PASS | 1m 6s | $0.00 |
| 02_remote_agent_server/01_convo_with_local_agent_server.py | ✅ PASS | 1m 1s | $0.07 |
| 02_remote_agent_server/02_convo_with_docker_sandboxed_server.py | ❌ FAIL Exit code 1 |
41.5s | -- |
| 02_remote_agent_server/03_browser_use_with_docker_sandboxed_server.py | ❌ FAIL Exit code 1 |
15.0s | -- |
| 02_remote_agent_server/04_convo_with_api_sandboxed_server.py | ❌ FAIL Exit code 1 |
1m 9s | -- |
| 02_remote_agent_server/05_vscode_with_docker_sandboxed_server.py | ❌ FAIL Exit code 1 |
12.7s | -- |
| 02_remote_agent_server/07_convo_with_cloud_workspace.py | ✅ PASS | 32.2s | $0.03 |
| 02_remote_agent_server/08_convo_with_apptainer_sandboxed_server.py | ❌ FAIL Exit code 1 |
2m 42s | -- |
| 04_llm_specific_tools/01_gpt5_apply_patch_preset.py | ✅ PASS | 20.6s | $0.02 |
| 04_llm_specific_tools/02_gemini_file_tools.py | ✅ PASS | 45.8s | $0.07 |
| 05_skills_and_plugins/01_loading_agentskills/main.py | ✅ PASS | 8.5s | $0.01 |
| 05_skills_and_plugins/02_loading_plugins/main.py | ✅ PASS | 4.8s | $0.01 |
❌ Some tests failed
Total: 37 | Passed: 30 | Failed: 7 | Total Cost: $1.76
Failed examples:
- examples/01_standalone_sdk/28_ask_agent_example.py: Exit code 1
- examples/01_standalone_sdk/30_tom_agent.py: Exit code 1
- examples/02_remote_agent_server/02_convo_with_docker_sandboxed_server.py: Exit code 1
- examples/02_remote_agent_server/03_browser_use_with_docker_sandboxed_server.py: Exit code 1
- examples/02_remote_agent_server/04_convo_with_api_sandboxed_server.py: Exit code 1
- examples/02_remote_agent_server/05_vscode_with_docker_sandboxed_server.py: Exit code 1
- examples/02_remote_agent_server/08_convo_with_apptainer_sandboxed_server.py: Exit code 1
|
Looks like there are a few issues preventing this PR from being merged!
If you'd like me to help, just leave a comment, like Feel free to include any additional details that might help me get this PR into a better state. You can manage your notification settings |
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
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.
Summary
This PR fixes the Docker/Apptainer sandboxed server example tests failing in CI (issue #1886) without downgrading Python 3.13.
Root Cause Analysis
Python 3.13 made a significant change to subprocess behavior (gh-113117):
This causes a race condition in libtmux where:
server.new_session()creates a tmux session viatmux new-sessionlist-sessionsto get full session infoposix_spawn(), the query can execute before tmux has fully registered the sessionThe Fix
This PR disables
posix_spawnspecifically for Python 3.13+ before importing libtmux:This is the official control knob provided by Python 3.13:
Alternative to PR #1910
This approach allows us to keep Python 3.13 in the Docker image instead of downgrading to Python 3.12.
Testing
The
test-exampleslabel triggers CI to:Note: Local testing cannot verify this fix because it requires a Docker image built with the fix. The pre-built
latest-pythonimage doesn't contain the fix.Fixes #1886