From 25967e8f34cff5a77f6f9c6a7b05ed9716b5942d Mon Sep 17 00:00:00 2001 From: Sam Gross Date: Tue, 11 Mar 2025 09:51:26 -0400 Subject: [PATCH] gh-130957: Use `sleeping_retry` in `test_free_reference` (GH-130958) The weak reference may not be immediately dead. (cherry picked from commit 19081158713526a3042c2ad3c6d5a589579b420f) Co-authored-by: Sam Gross --- Lib/test/test_concurrent_futures/executor.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Lib/test/test_concurrent_futures/executor.py b/Lib/test/test_concurrent_futures/executor.py index 1e7d4344740943..b3574c7c58af42 100644 --- a/Lib/test/test_concurrent_futures/executor.py +++ b/Lib/test/test_concurrent_futures/executor.py @@ -105,4 +105,7 @@ def test_free_reference(self): wr = weakref.ref(obj) del obj support.gc_collect() # For PyPy or other GCs. - self.assertIsNone(wr()) + + for _ in support.sleeping_retry(support.SHORT_TIMEOUT): + if wr() is None: + break