Repository navigation
test: print a hung test's greenlet stacks before the half-hour timeout - #6982
Merged
Merged
Conversation
faulthandler_timeout dumps every OS thread, but Playwright's sync API keeps the test's own frames in a suspended greenlet, so a hung browser test's dump shows only the event loop and never the line whose call is waiting. A minute before the timeout, the conftest now prints every greenlet's stack to the run's stderr. Nothing is stopped or failed by it. Refs #6807
ty rejected sys.__stderr__.fileno() since sys.__stderr__ may be None; fd 2 is the same descriptor, so behavior is unchanged.
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.
When a test outlives
faulthandler_timeout(30 minutes), the worker's dump lists every OS thread. Under Playwright's sync API, though, the test's own frames sit in a suspended greenlet, so the dump shows only Playwright's event loop and never the line whose call is waiting. #46 named this gap when it removed an earlier guard. It also left the one hang in #6807 (test_page_fixture_renders[feature-gallery]on macOS) with no location. Now, a minute before the timeout,tests/conftest.pyprints the stack of every suspended greenlet to the run's own stderr, next to faulthandler's dump. It only prints: no test is failed and no worker is stopped.To verify, I ran a scratch test that waits in
page.evaluate("() => new Promise(() => {})")with-o faulthandler_timeout=75, under both-n0and-n1. Before the change, the dump ended atplaywright/sync_api/_context_manager.py ... greenlet_main. After it, the output also holds the greenlet's stack, ending at the scratch test'sevaluateline. Then faulthandler's dump follows and the worker crashes as before.tests/modelpasses except for threetest_codex_adapter.pycases that fail the same way onmainin this sandbox (OSError: [Errno 97] Address family not supported).The stderr written to is a copy of fd 2 taken at
pytest_configure, because output capture redirectssys.stderrduring a test and that output would be lost when the worker exits.Refs #6807 — automated triage. This adds what the next hang will need for a diagnosis; it doesn't fix the hang, nor the document-scroll and quoting failures that issue also tracks.