Skip to content

gh-122957: Fix test flakiness in free-thread build #124039

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

lesteve
Copy link
Contributor

@lesteve lesteve commented Sep 13, 2024

Fix #122957.

Locally I tested this by running the test 1000 times with the command and the diff below. It fails around 10-20 times out of 1000 on main and does not fail out of 1000 times with the fix on this PR.

./python -m test.test_asyncio.test_threads -k concurrent -v
diff --git a/Lib/test/test_asyncio/test_threads.py b/Lib/test/test_asyncio/test_threads.py
index 774380270a7..8504544aaba 100644
--- a/Lib/test/test_asyncio/test_threads.py
+++ b/Lib/test/test_asyncio/test_threads.py
@@ -63,4 +63,10 @@ def get_ctx():
 
 
 if __name__ == "__main__":
-    unittest.main()
+    nb_tests = 1000
+    suite = unittest.TestSuite(
+        [ToThreadTests("test_to_thread_concurrent") for _ in range(nb_tests)]
+    )
+
+    test_runner = unittest.TextTestRunner()
+    test_runner.run(suite)

@ghost
Copy link

ghost commented Sep 13, 2024

All commit authors signed the Contributor License Agreement.
CLA signed

@bedevere-app
Copy link

bedevere-app bot commented Sep 13, 2024

Most changes to Python require a NEWS entry. Add one using the blurb_it web app or the blurb command-line tool.

If this change has little impact on Python users, wait for a maintainer to apply the skip news label instead.

@Eclips4 Eclips4 requested a review from colesbury September 13, 2024 08:51
@JelleZijlstra
Copy link
Member

Should we backport this to 3.12 and 3.13?

@colesbury
Copy link
Contributor

I think we've only ever seen the flakiness on the free-threaded build, so a backport to 3.12 is probably not necessary, although I think this is a pretty low risk change.

A backport to 3.13 would be good. Otherwise, we'll probably see flaky test failures in the free-threading buildbots. It's not urgent though, and can wait until after the final release if that's more convenient.

@colesbury colesbury added the needs backport to 3.13 bugs and security fixes label Sep 13, 2024
@JelleZijlstra
Copy link
Member

OK, let's merge this and it'll be up to Thomas whether to merge the 3.13 backport, or we can just do it after 3.13.0 goes out.

@JelleZijlstra JelleZijlstra merged commit eadb966 into python:main Sep 13, 2024
39 checks passed
@miss-islington-app
Copy link

Thanks @lesteve for the PR, and @JelleZijlstra for merging it 🌮🎉.. I'm working now to backport this PR to: 3.13.
🐍🍒⛏🤖

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Sep 13, 2024
@bedevere-app
Copy link

bedevere-app bot commented Sep 13, 2024

GH-124067 is a backport of this pull request to the 3.13 branch.

@bedevere-app bedevere-app bot removed the needs backport to 3.13 bugs and security fixes label Sep 13, 2024
@lesteve lesteve deleted the fix-free-threaded-asyncio-test-threads branch September 13, 2024 19:11
Yhg1s pushed a commit that referenced this pull request Sep 23, 2024
…uild (GH-124039) (#124067)

gh-122957: Fix test flakiness in asyncio test in free-thread build (GH-124039)
(cherry picked from commit eadb966)

Co-authored-by: Loïc Estève <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

test_asyncio test_to_thread_concurrent flaky
3 participants