Skip to content

ci: silence benign Windows asyncio cleanup warning in pytest#48

Open
ChenglongWang wants to merge 1 commit into
devfrom
ci/silence-windows-asyncio-warning
Open

ci: silence benign Windows asyncio cleanup warning in pytest#48
ChenglongWang wants to merge 1 commit into
devfrom
ci/silence-windows-asyncio-warning

Conversation

@ChenglongWang
Copy link
Copy Markdown
Contributor

Summary

CI on Windows surfaces a benign RuntimeError: Event loop is closed from CPython's ProactorEventLoop finalizing subprocess transports after the loop has closed. Pytest's unraisablehook turns it into a PytestUnraisableExceptionWarning, and GitHub Actions then misannotates the warning text (which contains the substring Error:) as a red error in the run summary — even though every test passes (conclusion: success).

This adds a single, narrowly-scoped filterwarnings entry under [tool.pytest.ini_options] that ignores only that exact warning class + message. Any other unraisable exception (real bugs) still surfaces normally.

filterwarnings = [
    "ignore:Exception ignored in.*BaseSubprocessTransport.*:pytest.PytestUnraisableExceptionWarning",
]

Verified locally: pre-filter the full suite reports 52 warnings, post-filter 51 warnings (the unraisable one is gone, no BaseSubprocessTransport / Event loop is closed lines appear in the warnings summary).

Test plan

  • pytest tests --no-cov: 1709 passed, 1 skipped (locally on macOS)
  • CI tests (py3.11 + py3.12 + Windows in agent-release matrix) stay green
  • Run summary on the next tag push no longer shows the red asyncio-cleanup annotation

CPython's ProactorEventLoop on Windows finalizes subprocess transports after
the event loop has closed, which raises RuntimeError("Event loop is closed")
inside BaseSubprocessTransport.__del__. Pytest's unraisablehook converts that
into a PytestUnraisableExceptionWarning, and GitHub Actions then misannotates
the warning text as an Error in the CI summary even though every test passes.

Add a scoped filterwarnings rule under [tool.pytest.ini_options] to ignore
exactly that warning class+message. Other unraisable exceptions still surface.

Made-with: Cursor
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant