From 3d99250b98a94a3a74134804602ff7d580e4a457 Mon Sep 17 00:00:00 2001 From: Wim Pomp Date: Mon, 4 Jan 2021 12:35:01 +0100 Subject: [PATCH] - force number of workers to be at least 2 - update readme --- README.md | 4 +++- parfor/__init__.py | 2 ++ setup.py | 2 +- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 4926b44..6255434 100644 --- a/README.md +++ b/README.md @@ -45,7 +45,9 @@ On OSX the buffer bar does not work due to limitations of the OS. desc: string with description of the progress bar bar: bool enable progress bar pbar: bool enable buffer indicator bar - nP: number of workers, default: number of cpu's/3 + rP: ratio workers to cpu cores, default: 1 + nP: number of workers, default, None, overrides rP if not None + number of workers will always be at least 2 serial: switch to serial if number of tasks less than serial, default: 4 debug: if an error occurs in an iteration, return the erorr instead of retrying in the main process diff --git a/parfor/__init__.py b/parfor/__init__.py index df329ff..a3c4967 100644 --- a/parfor/__init__.py +++ b/parfor/__init__.py @@ -167,6 +167,7 @@ def parfor(*args, **kwargs): pbar: bool enable buffer indicator bar rP: ratio workers to cpu cores, default: 1 nP: number of workers, default: None, overrides rP if not None + number of workers will always be at least 2 serial: switch to serial if number of tasks less than serial, default: 4 debug: if an error occurs in an iteration, return the erorr instead of retrying in the main process @@ -251,6 +252,7 @@ class parpool(object): self.nP = int(round(rP * multiprocessing.cpu_count())) else: self.nP = int(nP) + self.nP = max(self.nP, 2) self.fun = fun or (lambda x: x) self.args = args or () self.kwargs = kwargs or {} diff --git a/setup.py b/setup.py index 3b08ccb..572fae0 100644 --- a/setup.py +++ b/setup.py @@ -5,7 +5,7 @@ with open("README.md", "r") as fh: setuptools.setup( name="parfor", - version="2021.1.4", + version="2021.1.5", author="Wim Pomp", author_email="wimpomp@gmail.com", description="A package to mimic the use of parfor as done in Matlab.",