From bc3ff2835d24571ab5bb43f4178ad947c015a3e0 Mon Sep 17 00:00:00 2001 From: Sam Gross Date: Fri, 7 Mar 2025 12:16:09 -0500 Subject: [PATCH] gh-130957: Use sleeping_retry in test_free_reference The weak reference may not be immediately dead. --- 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 b97d9ffd94b1f8..dc92d2d7e4af92 100644 --- a/Lib/test/test_concurrent_futures/executor.py +++ b/Lib/test/test_concurrent_futures/executor.py @@ -129,4 +129,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