Skip to content

pytest is stuck in teardown when using uvloop #1134

Open
@sk-

Description

@sk-

First of all, thanks for the all the work put to release v1.0.0. It was really easy to migrate from v0.21. However we found a weird issue when using uvloop (based on the docs).

Using asyncio´s loop we had no issues and test would run normally. However, when using uvloop, tests would get silently stuck at the final teardown. After a lot of debugging I could track the issue to _provide_event_loop, which triggers a ResourceWarning in uvlopp's __uv_walk_close_all_handles_cb.

This warning is caught by pytest's catch_unraisable_exception, so maybe this issue will get resolved with pytest-dev/pytest#12958.

What made the issue hard to understand was the fact that no information was printed out, and that it only fails when warnings are treated as errors. I removed error from filterwarnings and the test passed without problem, but also without printing out the warnings.

At the end we kept errors in filterwarnings and added the entry ignore:unclosed resource <TCPTransport:ResourceWarning.

Below is a debugging capture of the warning producing the issue
Image

System info:
Python version: Python 3.12.9 (main, Feb 12 2025, 15:09:19) [Clang 19.1.6 ] on darwin
Pytest: 8.3.5
Pytest-asyncio: 1.0.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions