-
-
Save pitrou/a73fa2cfce2557e0dd435353b9976972 to your computer and use it in GitHub Desktop.
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
import sys | |
import threading | |
NLOOPS = 10 | |
NTHREADS = 30 | |
def t1(): | |
from concurrent.futures import ThreadPoolExecutor | |
def t2(): | |
from concurrent.futures.thread import ThreadPoolExecutor | |
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) | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment