Commits

Petar Marić  committed 49633e5

Properly terminate `multiprocessing` pool worker processes after calling `Pool.map()` to avoid turning them into zombie processes on Unix

  • Participants
  • Parent commits 8f6a315
  • Tags paper-characteristic-equation-roots-2013

Comments (0)

Files changed (1)

File beam_integrals/characteristic_equation_solvers.py

 
 def find_best_roots(beam_type, max_mode=DEFAULT_MAX_MODE,
     decimal_precision=DEFAULT_DECIMAL_PRECISION, include_error=True, **kwargs):
-    results = multiprocessing.Pool(
+    pool = multiprocessing.Pool(
         initializer=_init_pool,
         initargs=(beam_type, decimal_precision, include_error, kwargs)
-    ).map(
-        func=_worker,
-        iterable=range(1, max_mode+1)
     )
+    results = pool.map(func=_worker, iterable=range(1, max_mode+1))
+    
+    pool.close()
+    pool.join()
     return results