| 1 | import os |
| 2 | import sys |
| 3 | import threading |
| 4 | import traceback |
| 5 | |
| 6 | |
| 7 | NLOOPS = 50 |
| 8 | NTHREADS = 30 |
| 9 | |
| 10 | |
| 11 | def t1(): |
| 12 | try: |
| 13 | from concurrent.futures import ThreadPoolExecutor |
| 14 | except Exception: |
| 15 | traceback.print_exc() |
| 16 | os._exit(1) |
| 17 | |
| 18 | def t2(): |
| 19 | try: |
| 20 | from concurrent.futures.thread import ThreadPoolExecutor |
| 21 | except Exception: |
| 22 | traceback.print_exc() |
| 23 | os._exit(1) |
| 24 | |
| 25 | def 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 | |
| 37 | if __name__ == "__main__": |
| 38 | main() |