GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Optionally run Python regression tests in parallel · Issue #127933 · python/cpython

Optionally run Python regression tests in parallel #127933

New issue
Copy link
New issue
Copy link
Closed
Closed
Optionally run Python regression tests in parallel#127933
Copy link
Labels
testsTests in the Lib/test dirTests in the Lib/test dirtopic-free-threadingtype-featureA feature request or enhancementA feature request or enhancement

Description

@colesbury
colesbury
opened on Dec 13, 2024
Issue body actions

Feature or enhancement

This proposes adding an option to the regression test runner to run individual tests multiple times in parallel with the goal of uncovering multithreading bugs, especially in the free threading build.

Note that this is different from -j, --multiprocess, which uses multiple processes to run different tests files in parallel. The motivation of -j is to speed up the time it takes to run tests and the use of processes improves isolation. Here the goal is to detect thread-safety bugs (at the cost of extra time).

This is motivated by the experience of using https://github.com/Quansight-Labs/pytest-run-parallel, which is a pytest plugin written by @lysnikolaou and @andfoy. We've used that effectively to find thread-safety bugs in C API extensions while working on free threading compatibility.

The proposed changes are limited to the Python-internal test.regrtest and test.support package and not the public unittest package.

New command line arguments

These are chosen to match https://github.com/Quansight-Labs/pytest-run-parallel. I think using the same names across the Python ecosystem makes things a bit easier to remember if you work on multiple projects.

  • --parallel-threads=N [default=0], runs each test in N threads
  • --iterations=N [default=1], number of times to run each test

Other support

Some of our test cases are not thread-safe (even with the GIL) because they modify global state or use non thread-safe unsafe modules (like warnings):

  • @support.thread_unsafe - marks a test case as not safe to run in multiple threads. The test will be run once in the main thread (like normal) even when --parallel-threads=N is specified.

Similar projects

There are a few existing projects that do essentially this for pytest and unittest, but they're not directly usable for Python's own test suite.

  • https://github.com/Quansight-Labs/pytest-run-parallel
  • https://github.com/tonybaloney/pytest-freethreaded
  • https://github.com/amyreese/unittest-ft

Linked PRs

  • gh-127933: Add option to run regression tests in parallel #128003
Reacted by Tomas R., Kirill Podoprigora and Edgar Andrés Margffoy Tuay

Activity

  1. colesbury
    added
    type-featureA feature request or enhancementA feature request or enhancement
    testsTests in the Lib/test dirTests in the Lib/test dir
    topic-free-threading
    on Dec 13, 2024
  2. colesbury
    added 2 commits that reference this issue on Dec 16, 2024

    pythongh-127933: Add option to run regression tests in parallel

    8efef8e

    pythongh-127933: Add option to run regression tests in parallel

    c16bf01
  3. colesbury
    added 2 commits that reference this issue on Feb 4, 2025

    Merge branch 'main' into pythongh-127933-parallel-tests

    8470645

    gh-127933: Add option to run regression tests in parallel (gh-128003)

    e5f10a7
  4. srinivasreddy
    added a commit that references this issue on Feb 7, 2025

    pythongh-127933: Add option to run regression tests in parallel (pyth…

    68160cc
  5. cmaloney
    added a commit that references this issue on Feb 8, 2025

    pythongh-127933: Add option to run regression tests in parallel (pyth…

    4967ac0
  6. srinivasreddy commented on Feb 21, 2025

    @srinivasreddy
    srinivasreddy
    on Feb 21, 2025
    Contributor
    More actions

    We can close this ?

  7. kumaraditya303
    closed this as completedon Jul 14, 2025
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 dirTests in the Lib/test dirtopic-free-threadingtype-featureA feature request or enhancementA feature request or enhancement

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      You are visitor 01402520 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.