Skip to content

Instantly share code, notes, and snippets.

@xoelop
Created March 18, 2020 09:37
Show Gist options
  • Save xoelop/4a4f288707c4718dffea4e42844f08f2 to your computer and use it in GitHub Desktop.
Save xoelop/4a4f288707c4718dffea4e42844f08f2 to your computer and use it in GitHub Desktop.
Simple multithreading map function
import concurrent
def parallel_map(function, iterable, max_workers: int = 50):
with concurrent.futures.ThreadPoolExecutor(max_workers=max_workers) as pool:
result = pool.map(function, iterable)
return list(result)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment