Skip to content

Instantly share code, notes, and snippets.

@njsaunders
Last active June 11, 2025 13:28
Show Gist options
  • Save njsaunders/3f364f1c68325a80fae016de0bffe284 to your computer and use it in GitHub Desktop.
Save njsaunders/3f364f1c68325a80fae016de0bffe284 to your computer and use it in GitHub Desktop.
Python Multiprocessing
if "LAMBDA_TASK_ROOT" in os.environ:
from lambda_multiprocessing import Pool
else:
from multiprocessing import Pool
MULTIPROCESS_POOL_SIZE = int(os.environ.get("MULTIPROCESS_POOL_SIZE", "10"))
with Pool(MULTIPROCESS_POOL_SIZE) as pool:
enriched_branches = pool.map(enrich_branch, branches)
pool.close()
pool.join()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment