Skip to content

Documented uvloop pattern is deprecated #1346

Closed

Description

@tjkuson

Currently, the documentation suggests

import pytest
import uvloop


@pytest.fixture(scope="session")
def event_loop_policy():
    return uvloop.EventLoopPolicy()

EventLoopPolicy was deprecated in MagicStack/uvloop#638.

Activity

  1. seifertm commented on Jan 28, 2026

    @seifertm
    Contributor

    That makes sense. The policy system is also deprecated as of Python 3.14.

    pytest-asyncio doesn't really have a replacement yet. We want to keep the possibility to test with different loops, but didn't really find a suitable API for this so far. There's a draft PR that introduces a loop_factory argument to the asyncio marker, but it has some limitations.

  2. added theissue type on Jan 28, 2026
  3. tjkuson commented on Jan 28, 2026

    @tjkuson
    ContributorAuthor

    I assume you meant to link to #1164?

    Thanks for explaining, I'll read the thread and see if I have ideas when I next have some free time...

  4. changed the title [-]Documented `uvloop` pattern is depcreated[/-] [+]Documented `uvloop` pattern is deprecated[/+] on Jan 29, 2026
  5. added a commit that references this issue on Feb 8, 2026
    7dd8396
  6. ivanthewebber commented on Mar 9, 2026

    @ivanthewebber

    The text and the example in that documentation also doesn't match. I for one would appreciate it if that documentation could be improved in the meantime

  7. golikovichev commented on May 21, 2026

    @golikovichev

    +1 on ivanthewebber's note about the text/example mismatch. As a downstream user adopting pytest-asyncio for new projects, the current snippet is misleading on two fronts:

    1. uvloop.EventLoopPolicy() is deprecated since uvloop 0.21 (per Fix build for Python 3.14 MagicStack/uvloop#638) - calling it in the fixture emits a DeprecationWarning even before the test runs.
    2. Python 3.14 deprecates the policy system entirely per seifertm's note above, so any interim doc that still hangs off event_loop_policy will age fast.

    Two minimal interim options for the docs page (not blocking the long-term #1164 work):

    a) Replace the snippet with the asyncio.Runner(loop_factory=uvloop.new_event_loop) pattern (works today, sidesteps deprecation, but requires the user to wire it through pytest-asyncio).
    b) Keep the existing snippet but add a one-line callout noting both deprecations and pointing at #1164 for the future API direction.

    Happy to PR option (b) - one-paragraph callout, no API contract change - if maintainers prefer that as a holding pattern.

  8. tjkuson commented on May 21, 2026

    @tjkuson
    ContributorAuthor

    For what it's worth, this should be resolved once 1.4.0 is released (pre-releases are available if you'd like to try it out early).

  9. golikovichev commented on May 21, 2026

    @golikovichev

    Thanks for the heads-up. Will try v1.4.0a2 to confirm the new pattern. Dropping the interim docs callout offer since the structural fix is on its way.

  10. added this to the v1.4 milestone on May 26, 2026
  11. linked a pull request that will close this issueImplement event loop factory hook #1373on May 26, 2026
  12. seifertm commented on May 26, 2026

    @seifertm
    Contributor

    #1373 improves the documentation by mentioning the deprecation of the policy system and providing a non-deprecated approach in the how-to. I'd say this issue is sufficiently addressed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions