Skip to content
This repository was archived by the owner on Sep 11, 2023. It is now read-only.

Commit 00df5db

Browse files
authored
Use spawn() for multiprocessing instead of fork() (#1565)
* Use spawn() for starting new processes instead of fork() * multiprocess: Explicitly use spawn on linux, use the default on mac * Add changelog note for #1565
1 parent 109044a commit 00df5db

File tree

3 files changed

+10
-3
lines changed

3 files changed

+10
-3
lines changed

AUTHORS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,4 @@ Brooke Husic
2727
Tim Hempel
2828
Sander Roet
2929
Sebastian Falkner
30+
Finn Krein

doc/source/CHANGELOG.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ Changelog
1919
- Use :code:`int` instead of :code:`numpy.int` to solve :code:`numpy` 1.20
2020
DeprecationWarning :pr:`1504`
2121
- Umbrella sampling: fix periodic width initialization :pr:`1522`
22-
- Solve 2 code:`SyntaxWarnings: "is" with a literal.` in utils/reader_utils.py :pr:`1530`
22+
- Solve 2 code:`SyntaxWarnings: "is" with a literal.` in utils/reader_utils.py :pr:`1530`
23+
- Use spawn() for multiprocessing on linux instead of fork(), fixes worker processes sometimes going into idle for n_jobs>1 :pr:`1565`
2324

2425
2.5.7 (9-24-2019)
2526
-----------------

pyemma/_base/estimator.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@
2222
import sys
2323
import os
2424

25+
from platform import system
26+
from multiprocess import get_context
27+
2528
from threadpoolctl import threadpool_limits
2629

2730
from pyemma._ext.sklearn.base import BaseEstimator as _BaseEstimator
@@ -339,8 +342,10 @@ def estimate_param_scan(estimator, X, param_sets, evaluate=None, evaluate_args=N
339342
limit_threads)
340343
for estimator, param_set in zip(estimators, param_sets))
341344

342-
from pathos.multiprocessing import Pool
343-
pool = Pool(processes=n_jobs)
345+
if system() == "Linux":
346+
pool = get_context("spawn").Pool(processes=n_jobs)
347+
else:
348+
pool = get_context().Pool(processes=n_jobs)
344349
args = list(task_iter)
345350

346351
from contextlib import closing

0 commit comments

Comments
 (0)