-
-
Notifications
You must be signed in to change notification settings - Fork 30k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
Showing
5 changed files
with
81 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import multiprocessing | ||
import os | ||
import threading | ||
import traceback | ||
|
||
|
||
def t(): | ||
try: | ||
with multiprocessing.Pool(1): | ||
pass | ||
except Exception: | ||
traceback.print_exc() | ||
os._exit(1) | ||
|
||
|
||
def main(): | ||
threads = [] | ||
for i in range(20): | ||
threads.append(threading.Thread(target=t)) | ||
for thread in threads: | ||
thread.start() | ||
for thread in threads: | ||
thread.join() | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 2 additions & 0 deletions
2
Misc/NEWS.d/next/Core and Builtins/2021-03-16-17-12-54.bpo-43517.zAo6Ws.rst
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
Fix misdetection of circular imports when using ``from pkg.mod import | ||
attr``, which caused false positives in non-trivial multi-threaded code. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters