[Python-checkins] [3.12] Fix test_importlib.test_side_effect_import() (GH-104840) (#104842)

vstinner webhook-mailer at python.org
Wed May 24 20:36:19 EDT 2023


https://github.com/python/cpython/commit/51eb009cef155f02c59d05ce1f0d93c50ea9085a
commit: 51eb009cef155f02c59d05ce1f0d93c50ea9085a
branch: 3.12
author: Miss Islington (bot) <31488909+miss-islington at users.noreply.github.com>
committer: vstinner <vstinner at python.org>
date: 2023-05-25T02:36:13+02:00
summary:

[3.12] Fix test_importlib.test_side_effect_import() (GH-104840) (#104842)

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 <vstinner at python.org>

files:
M Lib/test/test_importlib/test_threaded_import.py

diff --git a/Lib/test/test_importlib/test_threaded_import.py b/Lib/test/test_importlib/test_threaded_import.py
index 85c3032aed53..68de4a66f3c7 100644
--- a/Lib/test/test_importlib/test_threaded_import.py
+++ b/Lib/test/test_importlib/test_threaded_import.py
@@ -238,7 +238,8 @@ def target():
         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):



More information about the Python-checkins mailing list