You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix: Eliminate port allocation race condition in all affected test files
Extended the fix from test_integration.py to all test files that suffered
from the same TOCTOU (Time-of-Check-Time-of-Use) race condition. When
running with pytest-xdist parallel workers, multiple workers would get
the same "free" port from `socket.bind(("127.0.0.1", 0))`, leading to:
- "address already in use" errors
- Tests connecting to wrong servers
Solution:
- Updated 7 test files to use `get_worker_specific_port(worker_id)`:
* tests/server/test_streamable_http_security.py
* tests/server/test_sse_security.py
* tests/shared/test_streamable_http.py (3 fixtures)
* tests/shared/test_sse.py
* tests/shared/test_ws.py
* tests/client/test_http_unicode.py
* tests/client/test_notification_response.py
- Fixed socket cleanup issue in tests/test_test_helpers.py
Each worker now gets an exclusive port range from 40000-59999, eliminating
the race condition across all test files that start servers.
Testing:
- All 703 tests pass with pytest-xdist parallel execution
- Port allocation now consistent across all parallel workers
0 commit comments