1import os 2import sys 3import threading 4import traceback 5 6 7NLOOPS = 50 8NTHREADS = 30 9 10 11def t1(): 12 try: 13 from concurrent.futures import ThreadPoolExecutor 14 except Exception: 15 traceback.print_exc() 16 os._exit(1) 17 18def t2(): 19 try: 20 from concurrent.futures.thread import ThreadPoolExecutor 21 except Exception: 22 traceback.print_exc() 23 os._exit(1) 24 25def main(): 26 for j in range(NLOOPS): 27 threads = [] 28 for i in range(NTHREADS): 29 threads.append(threading.Thread(target=t2 if i % 1 else t1)) 30 for thread in threads: 31 thread.start() 32 for thread in threads: 33 thread.join() 34 sys.modules.pop('concurrent.futures', None) 35 sys.modules.pop('concurrent.futures.thread', None) 36 37if __name__ == "__main__": 38 main() 39