Skip to content

Commit

Permalink
Merge pull request #46 from adrn/dill-multi
Browse files Browse the repository at this point in the history
Use multiprocess instead of multiprocessing
  • Loading branch information
adrn committed Mar 4, 2024
2 parents 4598c22 + cfaca99 commit 787213c
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 15 deletions.
7 changes: 7 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
version: 2
updates:
# Maintain dependencies for GitHub Actions
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "monthly"
6 changes: 1 addition & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,9 @@
# das Schwimmbad

[![image](https://github.com/adrn/schwimmbad/actions/workflows/tests.yml/badge.svg)](https://github.com/adrn/schwimmbad/actions/workflows/tests.yml)

[![image](https://github.com/adrn/schwimmbad/actions/workflows/ci.yml/badge.svg)](https://github.com/adrn/schwimmbad/actions/workflows/ci.yml)
[![image](http:https://img.shields.io/pypi/v/schwimmbad.svg?style=flat)](https://pypi.python.org/pypi/schwimmbad/)

[![image](http:https://img.shields.io/badge/license-MIT-blue.svg?style=flat)](https://github.com/adrn/schwimmbad/blob/master/LICENSE)

[![image](https://zenodo.org/badge/DOI/10.5281/zenodo.885577.svg)](https://zenodo.org/record/885577#.Wa9WVBZSy2w)

[![image](http:https://joss.theoj.org/papers/10.21105/joss.00357/status.svg)](http:https://dx.doi.org/10.21105/joss.00357)

`schwimmbad` provides a uniform interface to parallel processing pools and enables
Expand Down
5 changes: 2 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@ readme = "README.md"
license.file = "LICENSE"
requires-python = ">=3.9"
dynamic = ["version"]
dependencies = ["dill"]
dependencies = ["dill", "multiprocess"]

[project.optional-dependencies]
all = [
"joblib",
"mpi4py",
"mpi4py"
]
test = [
"schwimmbad[all]",
Expand All @@ -27,7 +27,6 @@ test = [
"pytest-astropy",
]
docs = [
"schwimmbad[all]",
"sphinx>=7.0",
"sphinx_copybutton",
"sphinx_autodoc_typehints",
Expand Down
16 changes: 9 additions & 7 deletions src/schwimmbad/multiprocessing.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
# type: ignore
import functools
import multiprocessing
import signal
from multiprocessing.pool import Pool

import multiprocess
from multiprocess.pool import Pool

__all__ = ["MultiPool"]

Expand Down Expand Up @@ -30,10 +31,12 @@ def __call__(self, tasks):

class MultiPool(Pool):
"""
A modified version of :class:`multiprocessing.pool.Pool` that has better
A modified version of :class:`multiprocess.pool.Pool` that has better
behavior with regard to ``KeyboardInterrupts`` in the :func:`map` method.
(Original author: `Peter K. G. Williams <[email protected]>`_)
NOTE: This is no longer built off of the standard library
:class:`multiprocessing.pool.Pool` -- this uses the version from `multiprocess`,
which uses `dill` to pickle objects instead of the standard library `pickle`.
Parameters
----------
Expand All @@ -46,8 +49,7 @@ class MultiPool(Pool):
Arguments for ``initializer``; it will be called as
``initializer(*initargs)``.
kwargs:
Extra arguments passed to the :class:`multiprocessing.pool.Pool`
superclass.
Extra arguments passed to the :class:`multiprocess.pool.Pool` superclass.
"""

Expand Down Expand Up @@ -104,7 +106,7 @@ def map(self, func, iterable, chunksize=None, callback=None):
try:
return r.get(self.wait_timeout)

except multiprocessing.TimeoutError:
except multiprocess.TimeoutError:
pass

except KeyboardInterrupt:
Expand Down

0 comments on commit 787213c

Please sign in to comment.