Fix race condition in new_session() by avoiding list-sessions query#625
Open
neubig wants to merge 3 commits intotmux-python:masterfrom
Open
Fix race condition in new_session() by avoiding list-sessions query#625neubig wants to merge 3 commits intotmux-python:masterfrom
neubig wants to merge 3 commits intotmux-python:masterfrom
Conversation
Previously, new_session() would run 'tmux new-session -P -F#{session_id}'
then immediately query 'tmux list-sessions' to fetch full session data.
This created a race condition in PyInstaller + Python 3.13+ + Docker
environments where list-sessions might not see the newly created session.
The fix expands the -F format string to include all Obj fields, parsing
the output directly into a Session object without a separate query.
Co-authored-by: openhands <openhands@all-hands.dev>
0f803dd to
e81a44f
Compare
Member
4 tasks
tony
reviewed
Feb 5, 2026
tony
reviewed
Feb 5, 2026
Co-authored-by: Tony Narlock <tony@git-pull.com>
Co-authored-by: Tony Narlock <tony@git-pull.com>
Author
|
Thanks @tony! Signed the CLA. I checked and the version is And in terms of CI where this failed, the reason why we were able to identify this is because this CI run failed: https://github.com/OpenHands/software-agent-sdk/actions/runs/21638051841/job/62369267088 We were able to trace it back to the upgrade from Python 3.12 to 3.13, and after reverting to 3.12, the consistent failures due to the issue I cited here disappeared (although this particular run still has a few failures): https://github.com/OpenHands/software-agent-sdk/actions/runs/21710957108 |
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.
Fixes: #624
Previously, new_session() would:
This created a race condition in some environments where list-sessions might not see the newly created session yet, causing TmuxObjectDoesNotExist errors.
The fix:
This is more efficient (one fewer subprocess call) and eliminates the race condition by making session creation atomic.
I tested this using the script in the original issue and it works in all three cases: