- force number of workers to be at least 2

- update readme
This commit is contained in:
Wim Pomp
2021-01-04 12:35:01 +01:00
parent 0721e2125c
commit 3d99250b98
3 changed files with 6 additions and 2 deletions

View File

@@ -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 desc: string with description of the progress bar
bar: bool enable progress bar bar: bool enable progress bar
pbar: bool enable buffer indicator 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 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 debug: if an error occurs in an iteration, return the erorr instead of retrying in the main process

View File

@@ -167,6 +167,7 @@ def parfor(*args, **kwargs):
pbar: bool enable buffer indicator bar pbar: bool enable buffer indicator bar
rP: ratio workers to cpu cores, default: 1 rP: ratio workers to cpu cores, default: 1
nP: number of workers, default: None, overrides rP if not None 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 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 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())) self.nP = int(round(rP * multiprocessing.cpu_count()))
else: else:
self.nP = int(nP) self.nP = int(nP)
self.nP = max(self.nP, 2)
self.fun = fun or (lambda x: x) self.fun = fun or (lambda x: x)
self.args = args or () self.args = args or ()
self.kwargs = kwargs or {} self.kwargs = kwargs or {}

View File

@@ -5,7 +5,7 @@ with open("README.md", "r") as fh:
setuptools.setup( setuptools.setup(
name="parfor", name="parfor",
version="2021.1.4", version="2021.1.5",
author="Wim Pomp", author="Wim Pomp",
author_email="wimpomp@gmail.com", author_email="wimpomp@gmail.com",
description="A package to mimic the use of parfor as done in Matlab.", description="A package to mimic the use of parfor as done in Matlab.",