Skip to content

Commit

Permalink
🚸 Terminate early on KeyboardInterrupt (#15)
Browse files Browse the repository at this point in the history
* 🚸 Terminate early on KeyboardInterrupt

* 👷 Run CI on 3.10

* ⬆️ Bump pytest

* ⬆️ Bump docs dependencies
  • Loading branch information
ddelange authored Oct 8, 2021
1 parent 3cc8cf7 commit e57761d
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 7 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [3.6, 3.7, 3.8, 3.9]
python-version: ['3.6', '3.7', '3.8', '3.9', '3.10']

steps:
- uses: actions/checkout@v2
Expand Down
2 changes: 1 addition & 1 deletion requirements/ci.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ pre-commit~=2.6.0
pytest-cov~=2.10.1
pytest-env~=0.6.2
pytest-sugar~=0.9.4
pytest~=4.6
pytest~=6.2
testfixtures~=6.14.1
pandas
6 changes: 3 additions & 3 deletions requirements/docs.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
recommonmark~=0.6
sphinx-rtd-theme~=0.5
sphinx~=3.2
recommonmark~=0.7
sphinx-rtd-theme~=1.0
sphinx~=4.2
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ def read_readme(path):
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Topic :: Software Development :: Libraries :: Python Modules",
"Topic :: Utilities",
],
Expand Down
4 changes: 2 additions & 2 deletions src/mapply/parallel.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ def multiprocessing_imap(
Raises:
Exception: Any error occurred during computation (will terminate the pool early).
KeyboardInterrupt: Any KeyboardInterrupt sent by the user (will terminate the pool early).
"""
n_chunks: Optional[int] = tqdm(iterable, disable=True).__len__() # doesn't exhaust
func = partial(func, *args, **kwargs)
Expand All @@ -100,10 +101,9 @@ def multiprocessing_imap(

try:
return list(stage)
except Exception:
except (Exception, KeyboardInterrupt):
if pool:
logger.debug("Terminating ProcessPool")
pool.close()
pool.terminate()
raise
finally:
Expand Down

0 comments on commit e57761d

Please sign in to comment.