FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Make it possible for faulthandler to terminate the pytest process on timeout by ogrisel · Pull Request #13679 · pytest-dev/pytest · GitHub

Make it possible for faulthandler to terminate the pytest process on timeout - #13679

Merged
RonnyPfannschmidt merged 19 commits into
pytest-dev:mainfrom
ogrisel:faulthandler-exit-on-timeout
Oct 6, 2025
Merged

Make it possible for faulthandler to terminate the pytest process on timeout#13679
RonnyPfannschmidt merged 19 commits into
pytest-dev:mainfrom
ogrisel:faulthandler-exit-on-timeout

Conversation

ogrisel commented Aug 27, 2025
edited
Loading

Copy link
Copy Markdown
Contributor

Closes #13678.

This would help projects avoid wasting their precious CI resources when running extensive thread-safety tests (which will become more popular in the new free-threading era).

I also changed the logic to mark the test as XFAIL conditionally on the presence of the "CI" environment variable instead of always skipping (related to #7022). This makes it possible to check that the test pass as expected when running locally.

If you think this is too risky, I can remove the condition and always mark the offending params with the xfail mark instead of skipping.

EDIT: I will do the later right away because I have already observed such a random failure on the CI: https://github.com/pytest-dev/pytest/actions/runs/17269674978/job/49010727146

EDIT 2: that does not work because xfail_strict = true is configured in pyproject.toml. Let me skip instead...

RonnyPfannschmidt left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

At first glance this looks nice

There may be some nitpicks but they relate to preexisting patterns

ogrisel commented Aug 27, 2025

Copy link
Copy Markdown
Contributor Author

I think I understand why the CI var was not properly detected: we probably need to add it to the passenv directive of tox. Let me try that quickly.

Comment thread src/_pytest/faulthandler.py Outdated

ogrisel commented Aug 27, 2025

Copy link
Copy Markdown
Contributor Author

Ok so many other unrelated test started to fail because they are not written in a way that expect to be ever executed in the presence of the CI environment variable... Let me revert 000876e and 5066d98...

Comment thread changelog/13678.feature.rst Outdated
Co-authored-by: 🇺🇦 Sviatoslav Sydorenko (Святослав Сидоренко) <wk.cvs.github@sydorenko.org.ua>

ogrisel commented Sep 3, 2025

Copy link
Copy Markdown
Contributor Author

I synced this PR with main as a follow-up on #13684. I think this PR is now ready for review. The matter of actually fixing #7022 is deferred to the exploratory #13695.

True,
marks=pytest.mark.skipif(
"CI" in os.environ, reason="sometimes crashes on CI (#7022)"
),

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

I changed the skip mark to a conditional mark to make it easy to check that this test actually passes locally.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Can it be an xfail, then?

ogrisel Sep 4, 2025
edited
Loading

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

I think I tried earlier, but this does not work because xfail_strict = true is configured in pyproject.toml and those tests would XPASS on most CI configurations except ubuntu-py314 that tends to fail for a reason I do not understand as investigated in #13695.

ogrisel commented Sep 9, 2025

Copy link
Copy Markdown
Contributor Author

I synced this PR with main after the recent merge of #13695 to see if the new test also fails on ubuntu-py314 or not. If the new test fails here, I will add the same conditional skip as done for test_timeout in #13695

ogrisel commented Sep 9, 2025
edited
Loading

Copy link
Copy Markdown
Contributor Author

The new test did not fail, but let me trigger it a few more times to check that it's not (too) flaky.

EDIT: the new test is also flaky, selectively on ubuntu-py314. Let me push a fix to conditionally skip it in cfa2aa6.

ogrisel commented Sep 9, 2025

Copy link
Copy Markdown
Contributor Author

I had a look at the codecov results and there is a single missing line:

https://app.codecov.io/gh/pytest-dev/pytest/pull/13679#f164a8d7864732ad2650984cfc20ed8e-R96

This line is actually covered in the new test, but the coverage data is not collected because the test uses a Python subprocess where coverage tracing is not enabled. I think collecting such coverage data is possible but out of the scope of the current PR.

ogrisel commented Sep 9, 2025

Copy link
Copy Markdown
Contributor Author

One of the CI jobs for cfa2aa6 failed for an unrelated problem (a transient codecov upload error). All the non-skipped tests actually passed.

ogrisel commented Sep 9, 2025

Copy link
Copy Markdown
Contributor Author

@RonnyPfannschmidt @webknjaz @nicoddemus I think this PR is ready for final review.

RonnyPfannschmidt left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Thanks for delivering this as well as gracefully fixing prerequisites

Copy link
Copy Markdown
Contributor

Awesome, thanks for working on this! I've triggered hangs like this in CI and resorted to using pytest-timeout as a workaround. It didn't occur to me that pytest itself can handle this.

ogrisel commented Sep 17, 2025

Copy link
Copy Markdown
Contributor Author

This week, we hit a random deadlock that caused a 6h CI timeout while releasing scikit-learn 1.7.2 on conda-forge. This is quite a waste of resources and slows down the release process by quite a lot when it happens. Having the option to configure pytest to early exit before the CI timeout would definitely help make our CI handling less painful.

Liam-DeVoe mentioned this pull request Oct 5, 2025
12 tasks
RonnyPfannschmidt merged commit 83da343 into pytest-dev:main Oct 6, 2025
33 checks passed

Copy link
Copy Markdown
Member

Sorry this took so long im slowly catching up

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

Labels

bot:chronographer:provided (automation) changelog entry is part of PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Make it possible to terminate pytest on deadlock after via the faulthandler timeout

4 participants


Back | FazBrowse Home | New Git URL