fix: Replace get_nowait() with get(timeout=5) in multiprocessing test#45
Merged
Conversation
get_nowait() raises _queue.Empty when the forked child process tries to read from the queue before serialized data is available. This is a race condition that triggers ~20% of the time under CPU pressure (e.g. Koji mock/nspawn builds). Using get(timeout=5) gives the child process time to receive the serialized INIConfig object, matching the pattern already used by the parent process on the result queue. Reproducer: 200 parallel stress runs — 39/200 failed before fix, 0/200 failed after. Assisted-by: AI
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.
Problem
TestIni.test_queueintests/test_multiprocessing.pyis flaky. The child process calls_q.get_nowait(), which raises_queue.Emptyif the serializedINIConfigobject hasn't arrived in the queue yet. This is a race condition betweenProcess.start()and the queue's internal pipe/buffer.The failure is rare on a normal workstation but triggers consistently (~20% failure rate) in resource-constrained or containerized build environments — specifically Koji mock builds using
systemd-nspawn, which is how CentOS Stream / RHEL RPMs are built. The%checkphase runsruntests.py, hits this race, and fails the entire package build.Fix
One-line change: replace
_q.get_nowait()with_q.get(timeout=5)in the child process. This gives the forked process time to receive the serialized object through the queue, matching the pattern already used by the parent on the result queue (w.get(timeout=1)).Reproducer
Stress test with 200 parallel runs under CPU contention: