Skip to content

Instantly share code, notes, and snippets.

Monday 10th June 2019 18:00
Tuesday 11th June 2019 18:00
Wednesday 12th June 2019 18:00
Thursday 13th June 2019 21:20
Friday 14th June 2019 18:00
Monday 3rd June 2019 21:20
@njsaunders
njsaunders / lambda_multiprocess.py
Created February 11, 2019 11:57
lambda_multiprocessing
from multiprocessing import Process, Pipe
def add_two(x, conn):
conn.send([x+2])
conn.close()
processes = []
parent_connections = []
xs = [1,2,3,4,5]
@njsaunders
njsaunders / multiprocess.py
Last active June 11, 2025 13:28
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()