Skip to content

Close the late-terminal discard stream without leaking ResourceWarning #4

Description

@dprada

What — Under a Python 3.14, 12-worker consumer suite, --receptor=llm reports a correct PASS but then prints repeated ResourceWarning: unclosed file ... /dev/null lines. The same suite with xdist and without pytest-receptor prints none.

How — pytest_receptor/plugin.py opens a discard stream in _silence_late_terminal() and keeps it in self._sink for pytest's late hooks, but never closes it. Reproduce with SMonitor's complete suite on Python 3.14.7, using a checkout based on uibcdf/smonitor@b00481d plus its local Python 3.14 candidate: run python -m pytest -q -n 12 -p xdist.plugin -p pytest_receptor.plugin --receptor=llm -p no:cacheprovider with plugin autoload disabled; then repeat without -p pytest_receptor.plugin and --receptor=llm. The first emits seven /dev/null warnings after PASS exit=0 | 465 passed, 2 skipped; the second emits none. A smaller pre-candidate suite showed the same warning shape after 461 passing tests.

Why — The warnings add noise and tokens after the bounded verdict, despite a successful test run. The fix must retain the late-terminal safety established by PR-PILOT-011: no trailing pytest banner, no closed-writer exception, and unchanged exit status, both with and without --receptor-stats and under xdist.

Record — devguide/pending_bugs/discard_stream_remains_unclosed_after_pytest.md

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions