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 — Annotate test cases which are timing sensitive · Issue #130363 · python/cpython

Annotate test cases which are timing sensitive #130363

New issue
Copy link
New issue
Copy link
Open
Open
Annotate test cases which are timing sensitive#130363
Copy link
Labels
testsTests in the Lib/test dirTests in the Lib/test dirtype-featureA feature request or enhancementA feature request or enhancement

Description

@rossburton
rossburton
opened on Feb 20, 2025
Issue body actions

Feature or enhancement

Proposal:

Many tests in the cpython test suite are sensitive to timing and assume an entirely unloaded system. For example, the TimerfdTests check for 1ms accuracy in expected durations. Some people (eg people building and testing python) may be running the test suite on build machines which are potentially heavily loaded so this sort of expectation isn't feasible.

It seems like a good solution to this would be to annotate the tests which are timing sensitive in some way, so they can be skipped easily.

For reference, we're manually patching python to skip tests which are failing under load but we're now having to rebase these patches on upgrades:

  • https://git.yoctoproject.org/poky/tree/meta/recipes-devtools/python/python3/0001-Skip-failing-tests-due-to-load-variability-on-YP-AB.patch
  • https://git.yoctoproject.org/poky/tree/meta/recipes-devtools/python/python3/0001-skip-no_stdout_fileno-test-due-to-load-variability.patch
  • https://git.yoctoproject.org/poky/tree/meta/recipes-devtools/python/python3/0001-test_active_children-skip-problematic-test.patch
  • https://git.yoctoproject.org/poky/tree/meta/recipes-devtools/python/python3/0001-test_deadlock-skip-problematic-test.patch
  • https://git.yoctoproject.org/poky/tree/meta/recipes-devtools/python/python3/0001-test_shutdown-skip-problematic-test.patch
  • https://git.yoctoproject.org/poky/tree/meta/recipes-devtools/python/python3/0001-test_storlines-skip-due-to-load-variability.patch

Has this already been discussed elsewhere?

No response given

Links to previous discussion of this feature:

No response

Linked PRs

  • gh-130363: add a test resource to mark tests that need an idle system #130508
Reacted by Sam James

Activity

Next
  1. rossburton
    added
    type-featureA feature request or enhancementA feature request or enhancement
    on Feb 20, 2025
  2. tomasr8
    added
    testsTests in the Lib/test dirTests in the Lib/test dir
    on Feb 20, 2025
  3. encukou commented on Feb 21, 2025

    @encukou
    encukou
    on Feb 21, 2025
    Member
    More actions

    Sounds like it could be a new resource, see python -m test --help and test.support.requires.

  4. tomasr8 commented on Feb 22, 2025

    @tomasr8
    tomasr8
    on Feb 22, 2025
    Member
    More actions

    I think it makes sense to hide the tests that clearly depend on timings (e.g. test_process_time) behind a test resource. Though for some of the other tests (e.g. test_input_no_stdout_fileno) it's not immediately obvious to me why they would fail, so perhaps instead of skipping them we could look into making them more reliable?

  5. rossburton commented on Feb 22, 2025

    @rossburton
    rossburton
    on Feb 22, 2025
    ContributorAuthor
    More actions

    Agreed - we've a short list of known flaky tests, and need to triage it to identify the ones which are genuinely sensitive vs those with subtle race conditions which should be fixed.

    I will prototype a new resource and see how it works.

  6. tomasr8 commented on Feb 22, 2025

    @tomasr8
    tomasr8
    on Feb 22, 2025
    Member
    More actions

    If it helps, to add a new resource, you just need to add it here:

    cpython/Lib/test/libregrtest/utils.py

    Lines 35 to 36 in d8ce092

    ALL_RESOURCES = ('audio', 'curses', 'largefile', 'network',
    'decimal', 'cpu', 'subprocess', 'urlfetch', 'gui', 'walltime')

    And then you can annotate the tests with @support.requires_resource('your_new_resource')

  7. picnixz commented on Feb 22, 2025

    @picnixz
    picnixz
    on Feb 22, 2025
    Member
    More actions

    Though for some of the other tests (e.g. test_input_no_stdout_fileno) it's not immediately obvious to me why they would fail, so perhaps instead of skipping them we could look into making them more reliable?

    How about a flaky resources. At least, we know which tests are meant to be flaky and which are not. And for the CI, we could ask the CI to rerun flaky tests on failures so that contributors don't need to wait for a triager/core dev to rerun a failed workflow when needed.

    I think it makes sense to hide the tests that clearly depend on timings (e.g. test_process_time) behind a test resource

    I suggest adding stats resources which could cover all tests that are meant to gather timing and check that some condition is statistically verified. Other possible names that are more or less generic: timeprec, measures, experiments. I don't really have better names =/

  8. tomasr8 commented on Feb 22, 2025

    @tomasr8
    tomasr8
    on Feb 22, 2025
    Member
    More actions

    I like the flaky test idea! For timing-related tests, I don't have a good suggestion either, though stats seems a bit too generic to me (but I guess how generic we want this resource to be). timeprec is more self-evident, or maybe timing or timings?

  9. picnixz commented on Feb 22, 2025

    @picnixz
    picnixz
    on Feb 22, 2025
    Member
    More actions

    I like the flaky test idea!

    Let's open a separate issue for the flaky tests as it could be orthogonal to tests that require an idle system due to stats gathering.

    I don't have a good suggestion either, though stats seems a bit too generic to me (but I guess how generic we want this resource to be). timeprec is more self-evident, or maybe timing or timings?

    I suggested "stats" because I don't think we should have a test that doesn't check against a population that some hypothesis is verified. However, I'm not sure we have any test that would test something else than timings like this. Memory cannot really be flaky unless the kernel is doing some weird stuff and network can fail but generally it's a timeout issue, not a data issue itself. So timings looks quite promising.

  10. tomasr8 commented on Feb 22, 2025

    @tomasr8
    tomasr8
    on Feb 22, 2025
    Member
    More actions

    Let's open a separate issue for the flaky tests as it could be orthogonal to tests that require an idle system due to stats gathering.

    Issue's here: #130474

    I suggested "stats" because I don't think we should have a test that doesn't check against a population that some hypothesis is verified. However, I'm not sure we have any test that would test something else than timings like this.

    Yeah, I'm not sure if we assert anything else besides timings that is similarly stochastic.. maybe we can stick with some time-related name for now and adjust it if something else comes up?

    Reacted by Bénédikt Tran
    Reacted by Bénédikt Tran
  11. rossburton
    added 2 commits that reference this issue on Feb 24, 2025

    pythongh-130363: add a test resource to mark tests that need an idle …

    c3b2f58

    pythongh-130363: add a test resource to mark tests that need an idle …

    9dfbe1e
  12. rossburton commented on Feb 24, 2025

    @rossburton
    rossburton
    on Feb 24, 2025
    ContributorAuthor
    More actions

    Posted a minimal PR: #130508. This just adds an "idle" resource.

  13. vstinner commented on Feb 24, 2025

    @vstinner
    vstinner
    on Feb 24, 2025
    Member
    More actions

    I'm not comfortable with this issue. "Skip tests because they fail on our CI" sounds too specific to me. IMO a "skip list" for a specific CI is perfectly fine.

    Your patches use the description:

    This test hangs frequently when run on the Autobuilder. Disable it in testing until the cause can be determined.

    Well, yes, the cause should be determined.

    0001-test_storlines-skip-due-to-load-variability.patch: it would be interesting to investigate why this specific test "intermittently fails on the Yocto AB when a worker is under heavy load".

    We already have the "walltime" resources for "slow tests". You might start by skipping this resource?

  14. rossburton commented on Feb 24, 2025

    @rossburton
    rossburton
    on Feb 24, 2025
    ContributorAuthor
    More actions

    Slow tests isn't a problem, it's tests that take 1s but have precise timing restrictions that are.

  15. 11 remaining items

  16. halstead
    added 6 commits that reference this issue on Aug 19, 2026

    python3: ptest: skip flaky test_attach_to_process_with_colors

    0253203

    python3: ptest: skip flaky test_attach_to_process_with_colors

    2f1482f

    python3: ptest: skip flaky test_attach_to_process_with_colors

    2ae8d8b

    python3: ptest: skip flaky test_attach_to_process_with_colors

    ea2ab4a

    python3: ptest: skip flaky test_interrupt on musl

    78e7bb0

    python3: ptest: skip flaky test_interrupt on musl

    7a7fbf9
  17. halstead
    added 5 commits that reference this issue on Sep 7, 2026

    python3: ptest: skip flaky test_attach_to_process_without_colors

    6682c47

    python3: ptest: skip flaky test_attach_to_process_without_colors

    8c4711e

    python3: ptest: skip flaky test_taskgroup_23

    3f46b3b

    python3: ptest: skip flaky test_taskgroup_23

    ecafd29

    python3: ptest: skip flaky test_taskgroup_23

    eb31aa1
  18. rossburton commented on Sep 24, 2026

    @rossburton
    rossburton
    on Sep 24, 2026
    ContributorAuthor
    More actions

    Another potentially timing sensitive test case in test_asyncio, although it might just be buggy: #158097.

  19. kevinprimeraquecreo-stack
    added this to Project_VKon Oct 18, 2026
  20. github-project-automation
    moved this to Todo in Project_VKon Oct 18, 2026
  21. kevinprimeraquecreo-stack
    added this to Project_VKon Oct 18, 2026
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 dirtype-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 01402503 — 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.