Repository navigation
Conversation
pytest-timeout covers only the test call and can't stop a main thread blocked outside Python, so one hang stalled a CI step for 20 minutes. The new timer dumps every stack and ends the process, and xdist then names the test that hung.
This branch has not been deployed
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.
What changed?
This PR adds a watchdog to the tests. If one test with its fixtures takes more than 300 s, the process prints the stack of every thread and exits, and xdist reports that test as crashed. The limit is the new ini option
test_hang_limit.Why?
A CI test step hangs now and then until its 20 minute limit, with no hint of which test it was.
pytest-timeoutcan't end such a hang. It covers only the test call (timeout_func_only), and its signal can't stop a main thread that is blocked in native code. The watchdog usesfaulthandler.dump_traceback_later, which runs on a C thread.It doesn't fix the hang. It makes the next one short and shows where it sits.
One point is open. The 300 s also count the session setup of the first test, with the download of the dev server.
How did you test it?
A test with a fixture teardown that sleeps hung the run before the change. With
-o test_hang_limit=10the run ends in 12 s, with the stack at the line that hangs and the name of the test. The whole suite passes on the local dev server and on the time-skipping server.Link to a test plan if any -