Skip to content

Commit

Permalink
Fix bug of more cpus being used than length of provided iterable; upd…
Browse files Browse the repository at this point in the history
…ate version
  • Loading branch information
zachbateman committed Nov 11, 2021
1 parent 878514c commit 60efdf8
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -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

Expand Down
2 changes: 2 additions & 0 deletions easy_multip/functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand Down
5 changes: 3 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@

setuptools.setup(
name='easy_multip',
version='0.3.3',
version='0.3.4',
packages=['easy_multip'],
license='MIT',
author='Zach Bateman',
description='Easy Python multiprocessing',
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',
Expand All @@ -23,5 +23,6 @@
'Programming Language :: Python :: 3.7',
'Programming Language :: Python :: 3.8',
'Programming Language :: Python :: 3.9',
'Programming Language :: Python :: 3.10',
]
)

0 comments on commit 60efdf8

Please sign in to comment.