fix: prevent handle inheritance in subprocess to resolve stdio deadlock#154
Merged
matt-landers merged 1 commit intoMay 15, 2026
Conversation
selutions
approved these changes
May 6, 2026
selutions
left a comment
There was a problem hiding this comment.
docs/tutorials/48-intent-based-authorization.md
jradcliff
reviewed
May 12, 2026
530d307 to
5213b0d
Compare
matt-landers
approved these changes
May 15, 2026
Member
|
This will go out with the 0.6.0 release next week. |
Contributor
Author
Thanks. Good to hear the PR is accepted & merged into main. All the best. |
|
@matt-landers does this also resolve #156 ? |
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.
Description
This PR addresses the remaining Windows deadlock issue over
stdiotransport.While PR #151 successfully moved client initialization to a background thread to prevent main-thread blocking, the underlying OS-level collision still persists: on Windows, the
subprocess.Popencall spawned bygoogle.auth.default()defaults tostdin=None. This causes the child process (e.g.,gcloud) to inherit the parent'sstdinhandle. Because the parent'sstdinis actively bound to theProactorEventLoop(Overlapped I/O) managing the MCPstdiotransport, this shared reference corrupts the pipe state, resulting in a hard crash ([WinError 6] The handle is invalidandValueError: I/O operation on closed pipe).To resolve this without altering the core initialization architecture or removing
gcloudfeature parity for Windows users, this fix introduces aprevent_stdio_inheritancecontext manager. It temporarily patchessubprocess.Popento enforcestdin=subprocess.DEVNULLduring thegoogle.auth.default()call. This isolates the standard file handles, preventing destructive inheritance while allowinggcloudto successfully fetch credentials.Changes
google.auth.default()inanalytics_mcp/tools/client.pywith aprevent_stdio_inheritancecontext manager.gcloud.stdiointegration harness. The server no longer hangs on initialization.blackand wrapped to the 80-character limit required bynox.Resolves #134