Created
January 11, 2024 04:59
-
-
Save jamesb93/477594e85d049ff1a2c52c2752ef5d6a to your computer and use it in GitHub Desktop.
multiple processing
This file contains hidden or 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 | |
def do_work(work_list): | |
with ThreadPoolExecutor() as pool: | |
def work(inp): | |
return f'{inp}----COMPLETE' | |
futures = [pool.submit(work, work_item) for work_item in work_list] | |
for future in futures: | |
print( future.result() ) | |
work_to_do = ['legs', 'arms', 'body', 'hands'] | |
do_work(work_to_do) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment