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 — Analyze and improve `test_asyncio.py`: right now it might be flaky · Issue #97546 · python/cpython

Analyze and improve test_asyncio.py: right now it might be flaky #97546

New issue
Copy link
New issue
Copy link
Closed
Closed
Analyze and improve test_asyncio.py: right now it might be flaky#97546
Copy link
Labels
testsTests in the Lib/test dirTests in the Lib/test dirtopic-asynciotype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error

Description

@sobolevn
sobolevn
opened on Sep 25, 2022
Issue body actions

Openning as proposed in #97535 (comment)

We had multiple issues with test_asyncio before. Some tests are changing env, some are just flaky:

  • asyncio pgo + lto buildbot failure: altered environment #97535
  • Running tests in parallel on Windows quits too soon #95027
  • test_asyncio environment changed during test execution due to empty threading._dangling without MainThread before some tests #91676
  • [Windows] : Proactor test_sendfile_close_peer_in_the_middle_of_receiving failure #85848
  • flaky test.test_asyncio.test_events.ProactorEventLoopTests.test_call_later #85801
  • test_asyncio: test_start_tls_server_1() fails randomly #76639
  • Any others?

It is proposed to analyze what is causing this to happen again and again.
And fix it, of course :)

Linked PRs

  • GH-97546: fix flaky asyncio test_wait_for_race_condition test #102421

Activity

  1. sobolevn
    added
    type-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
    topic-asyncio
    on Sep 25, 2022
  2. ezio-melotti
    added this to asyncioon Sep 25, 2022
  3. ezio-melotti
    moved this to Todo in asyncioon Sep 25, 2022
  4. sobolevn commented on Sep 25, 2022

    @sobolevn
    sobolevn
    on Sep 25, 2022
    MemberAuthor
    More actions

    This might be related: #93357

  5. gvanrossum commented on Sep 27, 2022

    @gvanrossum
    gvanrossum
    on Sep 27, 2022
    Member
    More actions

    Another possible source of flakiness is the use of small timeouts in tests, like 0.1 or even 0.01 seconds. Making the timeouts larger makes the tests run slower, but the short timeouts occasionally flake out. There should be other ways to wait for certain things to happen in most cases, like creating an Event object and awaiting that, instead of sleeping.

    Longer timeouts (e.g. 1, 2 or 3 seconds) are less likely to be suspicious, timeouts like that are meant to be never hit unless the test is actually failing. Making these too long would just cause tests to take longer to report failure.

  6. AlexWaygood
    added
    testsTests in the Lib/test dirTests in the Lib/test dir
    on Sep 27, 2022
  7. kumaraditya303 commented on Sep 29, 2022

    @kumaraditya303
    kumaraditya303
    on Sep 29, 2022
    Contributor
    More actions

    See also #82504

  8. arhadthedev commented on Mar 4, 2023

    @arhadthedev
    arhadthedev
    on Mar 4, 2023
    Member
    More actions

    test_asyncio is flaky again on ARM64 macOS randomly failing test_wait_for_race_condition. From https://buildbot.python.org/all/#builders/725/builds/3837 and https://buildbot.python.org/all/#builders/725/builds/3843:

    Traceback (most recent call last):
      File "/Users/buildbot/buildarea/3.x.pablogsal-macos-m1.macos-with-brew/build/Lib/asyncio/tasks.py", line 478, in wait_for
        return await fut
               ^^^^^^^^^
    asyncio.exceptions.CancelledError
    
    
    Traceback (most recent call last):
      File "/Users/buildbot/buildarea/3.x.pablogsal-macos-m1.macos-with-brew/build/Lib/unittest/async_case.py", line 90, in _callTestMethod
        if self._callMaybeAsync(method) is not None:
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "/Users/buildbot/buildarea/3.x.pablogsal-macos-m1.macos-with-brew/build/Lib/unittest/async_case.py", line 112, in _callMaybeAsync
        return self._asyncioRunner.run(
               ^^^^^^^^^^^^^^^^^^^^^^^^
      File "/Users/buildbot/buildarea/3.x.pablogsal-macos-m1.macos-with-brew/build/Lib/asyncio/runners.py", line 118, in run
        return self._loop.run_until_complete(task)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "/Users/buildbot/buildarea/3.x.pablogsal-macos-m1.macos-with-brew/build/Lib/asyncio/base_events.py", line 664, in run_until_complete
        return future.result()
               ^^^^^^^^^^^^^^^
      File "/Users/buildbot/buildarea/3.x.pablogsal-macos-m1.macos-with-brew/build/Lib/test/test_asyncio/test_waitfor.py", line 163, in test_wait_for_race_condition
        res = await task
              ^^^^^^^^^^
      File "/Users/buildbot/buildarea/3.x.pablogsal-macos-m1.macos-with-brew/build/Lib/asyncio/tasks.py", line 477, in wait_for
        async with timeouts.timeout(timeout):
      File "/Users/buildbot/buildarea/3.x.pablogsal-macos-m1.macos-with-brew/build/Lib/asyncio/timeouts.py", line 98, in __aexit__
        raise TimeoutError
    TimeoutError
    
  9. kumaraditya303
    added a commit that references this issue on Mar 5, 2023

    GH-97546: fix flaky asyncio `test_wait_for_race_condition` test (#102421

    a74cd3b
  10. hugovk
    added a commit that references this issue on Mar 6, 2023

    pythonGH-97546: fix flaky asyncio `test_wait_for_race_condition` test (…

    5a078fc
  11. carljm
    added 2 commits that reference this issue on Mar 6, 2023

    Merge branch 'main' into nodeaddict

    33dda2a

    Merge branch 'main' into inlinecomp2

    ecb313c
  12. kumaraditya303
    closed this as completedon Apr 19, 2023
  13. github-project-automation
    moved this from Todo to Done in asyncioon Apr 19, 2023
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-asynciotype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error

    Projects

    • asyncio
      Status
      Done
      Show more project fields

    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.