Commit e63d00f
committed
fix(batch): require both counts unchanged before the idle flush
The wait loop in the batching threads breaks out early when a second has
passed and nothing new arrived, but the guard ORs the two "unchanged"
checks:
if time.time() - start >= 1 and (
len_o == len(self.__batch_objects) or len_r == len(self.__batch_references)
):
In an objects-only batch -- what `add_object` without `add_reference`
produces -- `len_r` and `len(self.__batch_references)` are both always 0,
so the right operand is always True and the whole guard collapses to
`if time.time() - start >= 1`. The loop then stops waiting on the first
tick past one second no matter how fast objects are still streaming in,
so the batch is flushed well short of its configured size. A
references-only batch has the mirror-image problem.
The comment above the break says "no new objects were added in the last
second", i.e. the batch is idle -- which is true only when *both* counts
are unchanged. Switch `or` to `and` at the three places that share this
loop shape (sync.py, async_.py, base.py).
Fixes #21051 parent ae327ca commit e63d00f
3 files changed
Lines changed: 3 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
225 | 225 | | |
226 | 226 | | |
227 | 227 | | |
228 | | - | |
| 228 | + | |
229 | 229 | | |
230 | 230 | | |
231 | 231 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
434 | 434 | | |
435 | 435 | | |
436 | 436 | | |
437 | | - | |
| 437 | + | |
438 | 438 | | |
439 | 439 | | |
440 | 440 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
177 | 177 | | |
178 | 178 | | |
179 | 179 | | |
180 | | - | |
| 180 | + | |
181 | 181 | | |
182 | 182 | | |
183 | 183 | | |
| |||
0 commit comments