Proxy fails to start on Windows with AttributeError: module 'os' has no attribute 'WNOHANG'. - #23494
Merged
Merged
Conversation
Guard os.waitpid and os.WNOHANG usage with sys.platform check. These APIs are Unix-only; on Windows they cause AttributeError and prevent proxy startup. - _try_waitpid_watch: return False on Windows, fall back to os.kill polling - _reap_all_zombies: return empty set on Windows (no zombies) Add unit tests for Windows path. Made-with: Cursor
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Contributor
Greptile SummaryThis PR fixes a Windows-specific startup crash introduced in PR #21899, where the Prisma engine watchdog called
Confidence Score: 5/5
|
| Filename | Overview |
|---|---|
| litellm/proxy/utils.py | Adds sys.platform == "win32" guards to _reap_all_zombies and _try_waitpid_watch to prevent AttributeError on Windows where os.waitpid/os.WNOHANG are unavailable. The fix is minimal and correct; _try_pidfd_watch already had a hasattr(os, "pidfd_open") guard. The fallback to os.kill polling remains fully functional on Windows. |
| tests/litellm/proxy/test_prisma_engine_watchdog.py | Adds two new unit tests for the Windows early-return paths. Tests use patch("sys.platform", "win32") which correctly patches the global sys module. One subtle issue: existing Unix-only tests (e.g. test_try_waitpid_watch_returns_false_when_not_child) do not guard against running on Windows, where they would return False via the new Windows check rather than the ChildProcessError path — still passing, but for the wrong reason. |
Flowchart
%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[_start_engine_watcher] --> B[_try_waitpid_watch]
B -- "Windows: sys.platform == 'win32'" --> C[return False]
B -- "Unix: call os.waitpid with WNOHANG" --> D{is child?}
D -- No --> E[return False]
D -- Yes --> F[Start waitpid thread]
F --> G[return True]
C --> H[_try_pidfd_watch]
E --> H
H -- "no hasattr os.pidfd_open" --> I[return False]
H -- "Linux: pidfd_open succeeds" --> J[return True]
I --> K[os.kill polling fallback\n_poll_engine_proc every 1s]
subgraph "_reap_all_zombies"
L{sys.platform == 'win32'?}
L -- Yes --> M[return empty set]
L -- No --> N[os.waitpid -1 WNOHANG loop]
end
Last reviewed commit: 4e87fca
fzowl
pushed a commit
to fzowl/litellm
that referenced
this pull request
Jun 24, 2026
…#23494) Guard os.waitpid and os.WNOHANG usage with sys.platform check. These APIs are Unix-only; on Windows they cause AttributeError and prevent proxy startup. - _try_waitpid_watch: return False on Windows, fall back to os.kill polling - _reap_all_zombies: return empty set on Windows (no zombies) Add unit tests for Windows path. Made-with: Cursor
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.
Cause: PR #21899 added a Prisma engine watchdog that uses os.waitpid() and os.WNOHANG, which are Unix-only. On Windows these are missing and cause the crash.
Fix: Add sys.platform == "win32" checks so that on Windows _try_waitpid_watch returns False (falling back to os.kill polling) and _reap_all_zombies returns an empty set.
Relevant issues
Pre-Submission checklist
Please complete all items before asking a LiteLLM maintainer to review your PR
tests/test_litellm/directory, Adding at least 1 test is a hard requirement - see detailsmake test-unit@greptileaiand received a Confidence Score of at least 4/5 before requesting a maintainer reviewCI (LiteLLM team)
Branch creation CI run
Link:
CI run for the last commit
Link:
Merge / cherry-pick CI run
Links:
Type
🐛 Bug Fix
✅ Test
Changes