Repository navigation
fix: stop stray DistMaster coverage in xdist worker - #771
Open
jf-paquin-web wants to merge 1 commit into
Open
jf-paquin-web wants to merge 1 commit into
jf-paquin-web wants to merge 1 commit into
Conversation
jf-paquin-web
force-pushed
the
fix/xdist-worker-double-coverage
branch
from
October 29, 2026 16:35
24d6b81 to
7aa1540
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
xdist workers start with a copy of the master's args, so
-nis still set whenCovPlugin.__init__runs in a worker. As a result, each worker started aDistMaster, then started aDistWorkeron top of it without stopping the first one. Two collectors ended up on coverage's stack. Pausing the worker's coverage forno_coverbrought the stray tracer back, sono_covertests were still traced under xdist.worker: _prepareconfig(master args, -n still set) CovPlugin.__init__ start(DistMaster) # stray: erase() + cov.start() worker: pytest_sessionstart + cov_controller.cov.stop() # pop the stray collector start(DistWorker)Evidence
New test
test_no_cover_marker_stops_tracing(nodist / 1xdist / 2xdist / 3xdist). Each inner test records how many collectors are active and whether a tracer is set:collectors=2and theno_covertest still had a tracer.After: 4 passed. Normal test:
collectors=1.no_covertest:collectors=0,sys.gettrace() is None.Full
toxrun (pytest 9.0.2, xdist 3.8.0, coverage 7.13.5):Skips are pre-existing and platform-only: redis on macOS, SIGBREAK on Windows, and two PyPy-specific skips.