Skip to content

Instantly share code, notes, and snippets.

@pitrou
Last active March 16, 2021 14:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pitrou/a73fa2cfce2557e0dd435353b9976972 to your computer and use it in GitHub Desktop.
Save pitrou/a73fa2cfce2557e0dd435353b9976972 to your computer and use it in GitHub Desktop.
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