Skip to content

API for loop configuration options #1032

Open
@asvetlov

Description

@asvetlov

This issue doesn't propose a specific codebase change but is a point for discussing future steps in the plugin evolution.

Python has deprecated event loop policies since (unreleased) py-3.14.

The main asyncio motion idea for this and related changes is:

  1. Don't instantiate the loop explicitly, but use Runner (introduced in 3.11, there is a backport library for older Python version).
  2. Control runner behavior by debug and loop_factory arguments.
  3. There are eager tasks since 3.12; maybe the runner will have the option to configure it as well if we make an agreement

I think pytest-asyncio should reflect these changes.

  1. event_loop_policy() fixture should be deprecated along with event_loop.
  2. The library should not introduce public fixtures except unused_tcp_port and family. It is very fragile, especially if a user starts fixture overriding.
  3. Fine-grained control could be done by special pytest.mark.asyncio(...) arguments.
  4. Coarse-grained control uses configfile parameters and, maybe, cmdline args.
  5. Implementation details could vary; we are free to change them in the wild until the details are not leaked into the public space. The plugin already has a good movement in this direction, so I merely summarized what we do.

Please share your opinions in the comments, guys.

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