Commit a4c3330
fix(core): cancel pending fetches on early exit and stop-after-miss
Two related correctness issues in coalesced_get's drain loop:
1. When the consumer breaks out of the async-for (early exit), the
generator's finally block only awaited in-flight tasks rather than
cancelling them. That wasted I/O. Cancel first, then gather.
2. The drain loop waited on completion_queue for ``total`` entries, but
after a "missing" or "error" we cancel pending tasks -- and cancelled
tasks never enqueue a completion. With max_concurrency > 1 this could
hang. Rework the drain loop to break out immediately on the first
miss/error; the finally block handles cleanup.
The new structure also collapses the redundant miss/error branches and
removes the now-unused ``total``/``drained``/``stopped`` bookkeeping.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent b2ec638 commit a4c3330
1 file changed
Lines changed: 16 additions & 20 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
117 | 117 | | |
118 | 118 | | |
119 | 119 | | |
120 | | - | |
121 | | - | |
122 | 120 | | |
123 | 121 | | |
124 | 122 | | |
| |||
166 | 164 | | |
167 | 165 | | |
168 | 166 | | |
169 | | - | |
170 | | - | |
171 | 167 | | |
172 | | - | |
| 168 | + | |
173 | 169 | | |
174 | | - | |
175 | | - | |
176 | | - | |
177 | 170 | | |
178 | 171 | | |
179 | 172 | | |
180 | 173 | | |
181 | | - | |
182 | | - | |
183 | | - | |
184 | | - | |
185 | | - | |
186 | | - | |
187 | | - | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
188 | 183 | | |
189 | | - | |
190 | 184 | | |
191 | | - | |
192 | | - | |
193 | | - | |
| 185 | + | |
194 | 186 | | |
195 | 187 | | |
196 | 188 | | |
197 | | - | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
198 | 194 | | |
199 | 195 | | |
0 commit comments