Skip to content

Run the Python test suite in parallel by default #159155

Description

@vstinner

Currently, python -m test runs tests sequentially in a single process by default. It's slow and unsafe: if a test does crash, the whole test suite is interrupted, we don't exit cleanly, and resources may not be released properly (a temporary directory can be left behind).

I propose to run the Python test suite in parallel by default: choose the number of worker processes using os.process_cpu_count(). In short, make -j0 option the default. Running tests in parallel makes the task way faster (especially on machines with 8 CPUs or more). When using -j0, the test suite main process just watchs worker processes and is way likely to crash. When a worker process does crash, its working directory is removed cleanly. Also, when tests are interrupted by CTRL+C, the main process makes sure that all worker processes are stopped or killed (including child processes).

Instead, you will have to use --single-process explicitly to opt-in for Python 3.15 behavior: run tests sequentially in a single process.

Activity

  1. vstinner commented on Oct 10, 2026

    @vstinner
    MemberAuthor

    I'm working on a pull request to implement this change.

  2. cmaloney commented on Oct 10, 2026

    @cmaloney
    Contributor

    It would be nice if this picked up the make parallelism pieces when run under make test, either via MAKEFLAGS or https://www.gnu.org/software/make/manual/html_node/Job-Slots.html. Definitely can be an additional add-on feature though separate from the initial behavior change.

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

    testsTests in the Lib/test dirtype-featureA feature request or enhancement

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions