Skip to content

Running pytest in a sub-interpreter #13809

@bluetech

Description

@bluetech

Python 3.14 added a new module concurrent.interpreters which allows creating isolated sub-interpreters with their own GIL. I like the concept and experimented it with it a bit in pytest-xdist/execnet, trying to use sub-interperters instead of processes. I immediately ran into some problems.

But before getting into xdist and such (which share some issues with #13768, particularly around stdio capturing), the most basic thing is just running pytest in a single sub-interpreter:

from concurrent import interpreters

interp = interpreters.create()

interp.exec("""
import sys
sys.path.insert(0, "src")
import pytest
pytest.main()
""")

Here are the problems this runs into:

Metadata

Metadata

Assignees

No one assigned

    Labels

    type: enhancementnew feature or API change, should be merged into features branchtype: selftestsa problem in the tests of pytest

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions