Created
September 10, 2020 05:23
-
-
Save calpaterson/ab35377da9275ca3af7072dbd03ec3a6 to your computer and use it in GitHub Desktop.
thread starter
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
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