Skip to content

fix(tests): let collect_until run a second collection - #2482

Merged
JarryShaw merged 1 commit into
mainfrom
fix/2481-pypy-finaliser-backstop
Oct 31, 2026
Merged

JarryShaw merged 1 commit into
mainfrom
fix/2481-pypy-finaliser-backstop

Conversation

@JarryShaw

@JarryShaw JarryShaw commented Oct 31, 2026 •

Copy link
Copy Markdown
Owner
  • Searched for similar pull requests
  • Followed the coding style (make pylint, make mypy, make isort)
    • Note: isort -l100 -ppcapkit --check-only tests/_support.py flags the import block; left as is.
  • make test passes, and a test case covers the change
    • Note: only tests/foundation/test_extraction_ownership.py was run; make test was not.
  • Added a changelog entry under docs/source/changelog/ and regenerated CHANGELOG.md, if the change is user-visible
    • Note: N/A, centralised.

What is the purpose of your pull request?

  • fix — corrects a defect

Description of your pull request and other information

collect_until ended on the first collection once its grace ran out. PyPy 7.3.19 ran an abandoned extractor's finaliser only after a second collection (observed), so a slow first collection may have left the handle reported as still open (#2481). The cause is unverified; the fix matches the observed two-collection behaviour on PyPy. With a grace, collect_until cannot give up before MIN_COLLECTIONS_WITH_GRACE (2) collections. grace=0 is unchanged, as its existing test pins it.

Regression test: fake clock, each collection costs 2 s against a 1 s grace. It fails with the floor set to 1 and passes at 2.

Verified: tests/foundation/test_extraction_ownership.py 20/20 on CPython 3.14 and PyPy 3.10 (7.3.19). The CI failure did not reproduce in isolation, so the full-suite cause is UNVERIFIED.

Refs #2481

@JarryShaw JarryShaw added fix Pull requests that fix a defect (fix: subject prefix) review: pending No verdict for the current head - never reviewed, or the head moved since the last one labels Oct 31, 2026
@JarryShaw JarryShaw moved this to In review in PyPCAPKit Oct 31, 2026
@JarryShaw JarryShaw added review: running A cross-review is in flight against the current head - no verdict yet and removed review: pending No verdict for the current head - never reviewed, or the head moved since the last one labels Oct 31, 2026
@JarryShaw

Copy link
Copy Markdown
Owner Author

NEEDS CHANGES (Sonnet, 7025040c2). Fix is sound on CPython: the new test fails on the old helper, passes on the new one, and grace=0 is unchanged across callers.

  • tests/_support.py collect_until docstring: "after the first collection" and "done() held before the grace ran out" are false on the new path; document the two-collection floor. Rename local collections (~L1206), which shadows collections.abc.
  • PR body: "make isort already fails on main" is false (Makefile covers pcapkit, util, examples only). Reword. Changelog box: "N/A, centralised".
  • "measured" for two collections cites KTLO pypy3.10: finaliser backstop test fails on main #2481, which records no measurement. Say how it was measured or drop "measured".

@JarryShaw JarryShaw added review: needs-changes Cross-review at the current head says changes are required; see the verdict comment and removed review: running A cross-review is in flight against the current head - no verdict yet labels Oct 31, 2026
@JarryShaw
JarryShaw force-pushed the fix/2481-pypy-finaliser-backstop branch from 7025040 to 1780a9b Compare October 31, 2026 02:04
@JarryShaw JarryShaw added review: running A cross-review is in flight against the current head - no verdict yet and removed review: needs-changes Cross-review at the current head says changes are required; see the verdict comment labels Oct 31, 2026
@JarryShaw

Copy link
Copy Markdown
Owner Author

NEEDS CHANGES (Sonnet, 1780a9b4f). Shadowing, isort wording and the PyPy-two-collections claim are verified.

  • tests/_support.py: "at least MIN_COLLECTIONS_WITH_GRACE collections run" and the #: comment are false when done() holds after one collection. Say "cannot give up before N collections". Same fix in the body and commit message; the FINALISER_GRACE comment's "after the first gc.collect" contradicts the docstring.
  • PR body: "make test passes" is ticked with one module run; the changelog box is ticked with no entry. Leave both unticked with a note.
  • "a slow first collection reported the handle as still open" is stated as fact; the body calls the cause UNVERIFIED. Hedge it, and use Refs #2481 instead of Closes.

@JarryShaw JarryShaw added review: needs-changes Cross-review at the current head says changes are required; see the verdict comment and removed review: running A cross-review is in flight against the current head - no verdict yet labels Oct 31, 2026
@JarryShaw
JarryShaw force-pushed the fix/2481-pypy-finaliser-backstop branch from 1780a9b to e78e54b Compare October 31, 2026 02:17
@JarryShaw JarryShaw added review: running A cross-review is in flight against the current head - no verdict yet and removed review: needs-changes Cross-review at the current head says changes are required; see the verdict comment labels Oct 31, 2026
@JarryShaw

Copy link
Copy Markdown
Owner Author

NEEDS CHANGES (Sonnet, e78e54b41). The fix holds on CPython and PyPy; the wording is now true on the code.

@JarryShaw JarryShaw added review: needs-changes Cross-review at the current head says changes are required; see the verdict comment and removed review: running A cross-review is in flight against the current head - no verdict yet labels Oct 31, 2026
collect_until ended on the first collection once its grace ran out. PyPy
7.3.19 ran an abandoned extractor's finaliser only after a second
collection, so a slow first collection may have left the handle reported
as still open (#2481). The cause is unverified; the fix matches the
observed two-collection behaviour on PyPy.

With a grace, collect_until cannot give up before MIN_COLLECTIONS_WITH_GRACE
(2) collections. grace=0 is unchanged, as the existing helper test pins it.
Adds a fake-clock test that fails without the floor.

Refs #2481
@JarryShaw
JarryShaw force-pushed the fix/2481-pypy-finaliser-backstop branch from e78e54b to 1b34f0c Compare October 31, 2026 02:33
@JarryShaw JarryShaw added review: pending No verdict for the current head - never reviewed, or the head moved since the last one review: running A cross-review is in flight against the current head - no verdict yet review: good-to-go Cross-review at the current head says ready; CI state is separate and removed review: needs-changes Cross-review at the current head says changes are required; see the verdict comment review: pending No verdict for the current head - never reviewed, or the head moved since the last one review: running A cross-review is in flight against the current head - no verdict yet labels Oct 31, 2026
@JarryShaw
JarryShaw merged commit 9c0cabf into main Oct 31, 2026
29 checks passed
@JarryShaw
JarryShaw deleted the fix/2481-pypy-finaliser-backstop branch October 31, 2026 03:51
@github-project-automation github-project-automation Bot moved this from In review to Done in PyPCAPKit Oct 31, 2026
@JarryShaw JarryShaw removed the review: good-to-go Cross-review at the current head says ready; CI state is separate label Oct 31, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

fix Pull requests that fix a defect (fix: subject prefix)

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

1 participant