Skip to content

Instantly share code, notes, and snippets.

@jamesb93
Created January 11, 2024 04:59
Show Gist options
  • Save jamesb93/477594e85d049ff1a2c52c2752ef5d6a to your computer and use it in GitHub Desktop.
Save jamesb93/477594e85d049ff1a2c52c2752ef5d6a to your computer and use it in GitHub Desktop.
multiple processing
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