Commit 0bce36f
authored
Fix flaky client tests by waiting for first request's reply (#1091)
* Fix flaky client tests by waiting for first request's reply
The tests were sending two requests back-to-back:
1. First call without reply=True (to check msg_id is returned)
2. Second call with reply=True (to check reply content)
This caused flakiness because the reply for the first request would
sit in the channel, and _async_recv_reply would receive it but skip
it since msg_ids didn't match. On slow systems (like MacOS CI), the
second reply might not arrive before timeout.
Fix by using _recv_reply() / _async_recv_reply() to wait for the
first request's reply instead of sending a second request.
* Fix flaky client tests and handle flush race condition
Two fixes:
1. Fix flaky client tests by draining first reply before testing reply=True
The tests send two requests back-to-back:
- First call without reply=True (to check msg_id is returned)
- Second call with reply=True (to check reply content)
This caused flakiness because the reply for the first request would
sit in the channel, and _async_recv_reply would skip it since msg_ids
didn't match. On slow systems (like MacOS CI), the second reply might
not arrive before timeout.
Fix by draining the first reply before sending the second request.
This still tests both paths: returning msg_id and the reply=True
convenience functionality.
2. Handle stream closed between flush scheduling and execution
The _flush() callback runs on the ioloop thread after being scheduled
by flush(). Between scheduling and execution, the stream may be closed
by stop_channels() during teardown.
This is an expected race condition during shutdown, not a programming
error, so we handle it gracefully rather than asserting.
Uncovered by qtconsole downstream tests after #1089.1 parent a53ade9 commit 0bce36f
2 files changed
+40
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
214 | 214 | | |
215 | 215 | | |
216 | 216 | | |
217 | | - | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
218 | 224 | | |
219 | 225 | | |
220 | 226 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
50 | 50 | | |
51 | 51 | | |
52 | 52 | | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
53 | 56 | | |
54 | 57 | | |
55 | 58 | | |
56 | 59 | | |
57 | 60 | | |
58 | 61 | | |
59 | 62 | | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
60 | 66 | | |
61 | 67 | | |
62 | 68 | | |
63 | 69 | | |
64 | 70 | | |
65 | 71 | | |
66 | 72 | | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
67 | 76 | | |
68 | 77 | | |
69 | 78 | | |
70 | 79 | | |
71 | 80 | | |
72 | 81 | | |
73 | 82 | | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
74 | 86 | | |
75 | 87 | | |
76 | 88 | | |
77 | 89 | | |
78 | 90 | | |
79 | 91 | | |
80 | 92 | | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
81 | 96 | | |
82 | 97 | | |
83 | 98 | | |
| |||
150 | 165 | | |
151 | 166 | | |
152 | 167 | | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
153 | 171 | | |
154 | 172 | | |
155 | 173 | | |
156 | 174 | | |
157 | 175 | | |
158 | 176 | | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
159 | 180 | | |
160 | 181 | | |
161 | 182 | | |
162 | 183 | | |
163 | 184 | | |
164 | 185 | | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
165 | 189 | | |
166 | 190 | | |
167 | 191 | | |
168 | 192 | | |
169 | 193 | | |
170 | 194 | | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
171 | 198 | | |
172 | 199 | | |
173 | 200 | | |
174 | 201 | | |
175 | 202 | | |
176 | 203 | | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
177 | 207 | | |
178 | 208 | | |
179 | 209 | | |
180 | 210 | | |
181 | 211 | | |
182 | 212 | | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
183 | 216 | | |
184 | 217 | | |
185 | 218 | | |
| |||
0 commit comments