aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/Lib/test/test_importlib/partial/cfimport.py
diff options
context:
space:
mode:
authorAntoine Pitrou <antoine@python.org>2021-03-20 20:07:44 +0100
committerGitHub <noreply@github.com>2021-03-20 20:07:44 +0100
commit2fd16ef406bba239b1334057fb499496a84b3aa2 (patch)
tree0aca40303f31a7c1b22108eeba1afd9ae3b8ba60 /Lib/test/test_importlib/partial/cfimport.py
parent7cb033c423b65def1632d6c3c747111543b342a2 (diff)
downloadcpython-2fd16ef406bba239b1334057fb499496a84b3aa2.tar.gz
cpython-2fd16ef406bba239b1334057fb499496a84b3aa2.zip
bpo-43517: Fix false positive in detection of circular imports (#24895)
Diffstat (limited to 'Lib/test/test_importlib/partial/cfimport.py')
-rw-r--r--Lib/test/test_importlib/partial/cfimport.py38
1 files changed, 38 insertions, 0 deletions
diff --git a/Lib/test/test_importlib/partial/cfimport.py b/Lib/test/test_importlib/partial/cfimport.py
new file mode 100644
index 00000000000..c92d2fe1dd1
--- /dev/null
+++ b/Lib/test/test_importlib/partial/cfimport.py
@@ -0,0 +1,38 @@
+import os
+import sys
+import threading
+import traceback
+
+
+NLOOPS = 50
+NTHREADS = 30
+
+
+def t1():
+ try:
+ from concurrent.futures import ThreadPoolExecutor
+ except Exception:
+ traceback.print_exc()
+ os._exit(1)
+
+def t2():
+ try:
+ from concurrent.futures.thread import ThreadPoolExecutor
+ except Exception:
+ traceback.print_exc()
+ os._exit(1)
+
+def main():
+ for j in range(NLOOPS):
+ threads = []
+ for i in range(NTHREADS):
+ threads.append(threading.Thread(target=t2 if i % 1 else t1))
+ for thread in threads:
+ thread.start()
+ for thread in threads:
+ thread.join()
+ sys.modules.pop('concurrent.futures', None)
+ sys.modules.pop('concurrent.futures.thread', None)
+
+if __name__ == "__main__":
+ main()