Commit 04dc39b
committed
fix: Replace fixed sleep with active server readiness check in SSE tests
The test_sse_security_wildcard_ports test was flaky due to a race condition
where the test tried to connect before uvicorn was ready to accept connections.
The original code used time.sleep(1) which was:
- Sometimes too short (causing flaky CI failures)
- Always wasteful when server started quickly
- Non-deterministic
This change replaces the arbitrary sleep with wait_for_server() which:
- Actively polls the server port until it accepts connections
- Returns immediately when ready (faster in most cases)
- Has a clear 5-second timeout for true failures
- Eliminates the race condition entirely
The fix makes the tests deterministic and often faster than before.1 parent 7ac40af commit 04dc39b
1 file changed
+22
-2
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
66 | 66 | | |
67 | 67 | | |
68 | 68 | | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
69 | 89 | | |
70 | 90 | | |
71 | 91 | | |
72 | 92 | | |
73 | | - | |
74 | | - | |
| 93 | + | |
| 94 | + | |
75 | 95 | | |
76 | 96 | | |
77 | 97 | | |
| |||
0 commit comments