From 60efdf8c9bbdee3991acbe1aa7d2bbdad7cd92b3 Mon Sep 17 00:00:00 2001 From: Zach Bateman Date: Wed, 10 Nov 2021 18:43:37 -0600 Subject: [PATCH] Fix bug of more cpus being used than length of provided iterable; update version --- README.md | 2 +- easy_multip/functions.py | 2 ++ setup.py | 5 +++-- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 8301f99..2a7caef 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # easy_multip -easy_multip is a small tool designed to quickly allow Python multiprocessing capabilities while greatly simplifying code for easier use. +easy_multip is a small tool designed to simplify Python multiprocessing capabilities. # Current Features diff --git a/easy_multip/functions.py b/easy_multip/functions.py index 2c37fbc..7a67560 100644 --- a/easy_multip/functions.py +++ b/easy_multip/functions.py @@ -71,6 +71,8 @@ def doloop(expensive_func, iterable, leave_one_cpu_free=True, num_cpu: int=0, ve Alternatively, num_cpus can be specified to use a specific number of cores. ''' num_cpus = _num_cpus(leave_one_cpu_free) if num_cpu == 0 else num_cpu + if num_cpus > len(iterable): # don't need or want more processes than length of the iterable + num_cpus = len(iterable) # next lines most evenly spread out data args into groups for processes iterable_groups = [[] for _ in range(num_cpus)] diff --git a/setup.py b/setup.py index 98e5b36..e42de2c 100644 --- a/setup.py +++ b/setup.py @@ -5,7 +5,7 @@ setuptools.setup( name='easy_multip', - version='0.3.3', + version='0.3.4', packages=['easy_multip'], license='MIT', author='Zach Bateman', @@ -13,7 +13,7 @@ long_description=long_description, long_description_content_type='text/markdown', url='https://github.com/zachbateman/easy_multip.git', - download_url='https://github.com/zachbateman/easy_multip/archive/v_0.3.3.tar.gz', + download_url='https://github.com/zachbateman/easy_multip/archive/v_0.3.4.tar.gz', keywords=['MULTIPROCESSING', 'SIMPLE', 'EASY', 'PARALLEL'], install_requires=['tqdm'], classifiers=['Development Status :: 3 - Alpha', @@ -23,5 +23,6 @@ 'Programming Language :: Python :: 3.7', 'Programming Language :: Python :: 3.8', 'Programming Language :: Python :: 3.9', + 'Programming Language :: Python :: 3.10', ] )