Skip to content

Respect the existing deadline when waiting for a partial batch - #60

Merged
wolph merged 1 commit into
wolph:developfrom
harbinresearcher:codex/preserve-abatcher-deadline
Oct 18, 2026
Merged

wolph merged 1 commit into
wolph:developfrom
harbinresearcher:codex/preserve-abatcher-deadline

Conversation

@harbinresearcher

Copy link
Copy Markdown
Contributor

Closes #59.

abatcher waits a full interval for each next item, even when a nonempty batch already has a deadline. With interval10 and arrivals0 and8, a blocked next item delays the batch until18. The strict deadline comparison also postpones a batch whose last item arrives exactly at10 until20.

Use the remaining deadline for a nonempty batch, clamped to zero, and flush when the deadline is reached. Empty batches retain a full wait so an expired idle deadline cannot cause a busy loop. Existing resets after time/size flushes and pending-source cancellation are preserved. The docstring and changelog describe the timing correction.

Eight deterministic regressions cover arrivals before/on the deadline, numeric/timedelta intervals, and interval-only/size+interval batching. The existing fake-clock test now states both expected batch sequences explicitly: its at-deadline case flushes at equality rather than including the next item.

Validation:

  • New regressions against original code:8failed, with flush times18/20 instead of10. Patched generator module:20passed.
  • Windows CPython3.12.14 full configured suite:361→369passed, the same5IANA timezone-data skips; both100% configured branch coverage.
  • Linux CPython3.10.22 and3.14.8 full configured suites:366→374passed in each, both baseline and patch100% configured branch coverage. Linux dependencies resolved with the project's14-day cutoff.
  • Ruff lint/format, mypy, basedpyright, pyrefly, codespell, and Sphinx warnings-as-errors passed on both pristine and patched Linux checkouts. Windows type checks also passed after explicitly selecting the task environment.
  • Isolated sdist and wheel build passed. The built wheel was installed into a separate target, its import path verified, and all20generator tests passed from that installed module.
  • Independent automated read-only review found no actionable issues. Additional controlled-clock/Future-source probes covered cold idle, late arrivals, consumer pauses and an expired deadline clamped to zero.

AI assistance was used for investigation, implementation, tests, review and this description. No local PyPy/macOS or full interpreter-matrix claim. This fixes the requested wait and deadline comparison; it cannot guarantee scheduling latency on a blocked event loop.

@wolph
wolph merged commit 1a93d74 into wolph:develop Oct 18, 2026
17 checks passed
wolph added a commit that referenced this pull request Oct 18, 2026
…after #60

The 4.1.2 test suite pins that an item arriving exactly at the deadline
joins the batch it was waiting on. Flush a nonempty batch when the wait
runs out instead of comparing the clock with >=, so the deadline from
#60 still holds and the old grouping stays.
wolph added a commit that referenced this pull request Oct 18, 2026
@wolph

wolph commented Oct 18, 2026

Copy link
Copy Markdown
Owner

Thank you for the fix and the thorough tests! Waiting a full interval again for every item was never the intent, so this makes abatcher do what the docs already promised :)

I've made one small change on top in 7cdd759: an item that arrives exactly at the deadline still joins the batch it was waiting on, since the 4.1.2 tests pin that, and the batch flushes at the deadline instead of an interval later. Beyond that everything is merged as it is.

@wolph

wolph commented Oct 19, 2026

Copy link
Copy Markdown
Owner

I've created a new release (v4.1.3) which includes your fix, thanks again for the help :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

abatcher waits a full interval again while a partial batch is pending

2 participants