Skip to content

Instantly share code, notes, and snippets.

@calpaterson
Created September 10, 2020 05:23
Show Gist options
  • Save calpaterson/ab35377da9275ca3af7072dbd03ec3a6 to your computer and use it in GitHub Desktop.
Save calpaterson/ab35377da9275ca3af7072dbd03ec3a6 to your computer and use it in GitHub Desktop.
thread starter
from concurrent.futures import ThreadPoolExecutor
from os import getpid
from time import sleep
executor = ThreadPoolExecutor(max_workers=20)
def print_pid_and_sleep():
while True:
print(getpid())
sleep(10)
for _ in range(20):
executor.submit(print_pid_and_sleep)
executor.shutdown()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment