@@ -92,9 +92,16 @@ def evaluate_grid(
9292
9393 from concurrent .futures .process import BrokenProcessPool
9494
95+ from benchmarks .common import _init_worker
96+
9597 def _make_pool () -> ProcessPoolExecutor :
9698 ctx = mp .get_context ("spawn" )
97- p = ProcessPoolExecutor (max_workers = workers , mp_context = ctx , max_tasks_per_child = 50 )
99+ p = ProcessPoolExecutor (
100+ max_workers = workers ,
101+ mp_context = ctx ,
102+ max_tasks_per_child = 50 ,
103+ initializer = _init_worker ,
104+ )
98105 list (p .map (int , range (workers ))) # eager-spawn all workers
99106 return p
100107
@@ -193,9 +200,16 @@ def evaluate_grid_cached( # noqa: C901 — pool teardown + per-cell demux + ret
193200 if needed :
194201 pending .append ((inst , needed ))
195202
203+ from benchmarks .common import _init_worker
204+
196205 def _make_pool () -> ProcessPoolExecutor :
197206 ctx = mp .get_context ("spawn" )
198- p = ProcessPoolExecutor (max_workers = workers , mp_context = ctx , max_tasks_per_child = 40 )
207+ p = ProcessPoolExecutor (
208+ max_workers = workers ,
209+ mp_context = ctx ,
210+ max_tasks_per_child = 40 ,
211+ initializer = _init_worker ,
212+ )
199213 list (p .map (int , range (workers )))
200214 return p
201215
0 commit comments