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

Commit

Permalink
Use spawn() for multiprocessing instead of fork() (#1565)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
sents committed May 25, 2022
1 parent 109044a commit 00df5db
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
1 change: 1 addition & 0 deletions AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,4 @@ Brooke Husic
Tim Hempel
Sander Roet
Sebastian Falkner
Finn Krein
3 changes: 2 additions & 1 deletion doc/source/CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ Changelog
- Use :code:`int` instead of :code:`numpy.int` to solve :code:`numpy` 1.20
DeprecationWarning :pr:`1504`
- Umbrella sampling: fix periodic width initialization :pr:`1522`
- Solve 2 code:`SyntaxWarnings: "is" with a literal.` in utils/reader_utils.py :pr:`1530`
- Solve 2 code:`SyntaxWarnings: "is" with a literal.` in utils/reader_utils.py :pr:`1530`
- Use spawn() for multiprocessing on linux instead of fork(), fixes worker processes sometimes going into idle for n_jobs>1 :pr:`1565`

2.5.7 (9-24-2019)
-----------------
Expand Down
9 changes: 7 additions & 2 deletions pyemma/_base/estimator.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@
import sys
import os

from platform import system
from multiprocess import get_context

from threadpoolctl import threadpool_limits

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

from pathos.multiprocessing import Pool
pool = Pool(processes=n_jobs)
if system() == "Linux":
pool = get_context("spawn").Pool(processes=n_jobs)
else:
pool = get_context().Pool(processes=n_jobs)
args = list(task_iter)

from contextlib import closing
Expand Down

0 comments on commit 00df5db

Please sign in to comment.