From: Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> Date: Thu, 25 May 2023 00:35:34 +0000 (-0700) Subject: [3.11] Fix test_importlib.test_side_effect_import() (GH-104840) (#104843) X-Git-Tag: v3.11.4~27 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=76873ca6b1ad1a1eb9518f0ff7fc594ec96d0a65;p=thirdparty%2FPython%2Fcpython.git [3.11] Fix test_importlib.test_side_effect_import() (GH-104840) (#104843) Fix test_importlib.test_side_effect_import() (GH-104840) Wait until the thread spawn by the import completes to avoid dangling threads. With this fix, the following command no longer fails: ./python -m test --fail-env-changed test_importlib -m test_side_effect_import -F -j20 (cherry picked from commit 426950993f6a39cdf3f6a3333ac8b518833c7e61) Co-authored-by: Victor Stinner --- diff --git a/Lib/test/test_importlib/test_threaded_import.py b/Lib/test/test_importlib/test_threaded_import.py index 9aeeb5e686e9..16c0513b585a 100644 --- a/Lib/test/test_importlib/test_threaded_import.py +++ b/Lib/test/test_importlib/test_threaded_import.py @@ -244,7 +244,8 @@ class ThreadedImportTests(unittest.TestCase): self.addCleanup(forget, TESTFN) self.addCleanup(rmtree, '__pycache__') importlib.invalidate_caches() - __import__(TESTFN) + with threading_helper.wait_threads_exit(): + __import__(TESTFN) del sys.modules[TESTFN] def test_concurrent_futures_circular_import(self):