better multiprocessing and multithreading in Python
Project description
About Multiprocess
multiprocess is a fork of multiprocessing. multiprocess extends multiprocessing to provide enhanced serialization, using dill. multiprocess leverages multiprocessing to support the spawning of processes using the API of the Python standard library’s threading module. multiprocessing has been distributed as part of the standard library since Python 2.6.
multiprocess is part of pathos, a Python framework for heterogeneous computing. multiprocess is in active development, so any user feedback, bug reports, comments, or suggestions are highly appreciated. A list of issues is located at https://github.com/uqfoundation/multiprocess/issues, with a legacy list maintained at https://uqfoundation.github.io/project/pathos/query.
Major Features
multiprocess enables:
objects to be transferred between processes using pipes or multi-producer/multi-consumer queues
objects to be shared between processes using a server process or (for simple data) shared memory
multiprocess provides:
equivalents of all the synchronization primitives in threading
a Pool class to facilitate submitting tasks to worker processes
enhanced serialization, using dill
Current Release
The latest released version of multiprocess is available from:
multiprocess is distributed under a 3-clause BSD license, and is a fork of multiprocessing.
Development Version
You can get the latest development version with all the shiny new features at:
If you have a new contribution, please submit a pull request.
Installation
multiprocess can be installed with pip:
$ pip install multiprocess
For Python 2, a C compiler is required to build the included extension module from source. Python 3 and binary installs do not require a C compiler.
Requirements
multiprocess requires:
python (or pypy), >=3.8
setuptools, >=42
dill, >=0.3.9
Basic Usage
The multiprocess.Process class follows the API of threading.Thread. For example
from multiprocess import Process, Queue def f(q): q.put('hello world') if __name__ == '__main__': q = Queue() p = Process(target=f, args=[q]) p.start() print (q.get()) p.join()
Synchronization primitives like locks, semaphores and conditions are available, for example
>>> from multiprocess import Condition >>> c = Condition() >>> print (c) <Condition(<RLock(None, 0)>), 0> >>> c.acquire() True >>> print (c) <Condition(<RLock(MainProcess, 1)>), 0>
One can also use a manager to create shared objects either in shared memory or in a server process, for example
>>> from multiprocess import Manager >>> manager = Manager() >>> l = manager.list(range(10)) >>> l.reverse() >>> print (l) [9, 8, 7, 6, 5, 4, 3, 2, 1, 0] >>> print (repr(l)) <Proxy[list] object at 0x00E1B3B0>
Tasks can be offloaded to a pool of worker processes in various ways, for example
>>> from multiprocess import Pool >>> def f(x): return x*x ... >>> p = Pool(4) >>> result = p.map_async(f, range(10)) >>> print (result.get(timeout=1)) [0, 1, 4, 9, 16, 25, 36, 49, 64, 81]
When dill is installed, serialization is extended to most objects, for example
>>> from multiprocess import Pool >>> p = Pool(4) >>> print (p.map(lambda x: (lambda y:y**2)(x) + x, xrange(10))) [0, 2, 6, 12, 20, 30, 42, 56, 72, 90]
More Information
Probably the best way to get started is to look at the documentation at http://multiprocess.rtfd.io. Also see multiprocess.tests for scripts that demonstrate how multiprocess can be used to leverge multiple processes to execute Python in parallel. You can run the test suite with python -m multiprocess.tests. As multiprocess conforms to the multiprocessing interface, the examples and documentation found at http://docs.python.org/library/multiprocessing.html also apply to multiprocess if one will import multiprocessing as multiprocess. See https://github.com/uqfoundation/multiprocess/tree/master/py3.12/examples for a set of examples that demonstrate some basic use cases and benchmarking for running Python code in parallel. Please feel free to submit a ticket on github, or ask a question on stackoverflow (@Mike McKerns). If you would like to share how you use multiprocess in your work, please send an email (to mmckerns at uqfoundation dot org).
Citation
If you use multiprocess to do research that leads to publication, we ask that you acknowledge use of multiprocess by citing the following in your publication:
M.M. McKerns, L. Strand, T. Sullivan, A. Fang, M.A.G. Aivazis, "Building a framework for predictive science", Proceedings of the 10th Python in Science Conference, 2011; http://arxiv.org/pdf/1202.1056 Michael McKerns and Michael Aivazis, "pathos: a framework for heterogeneous computing", 2010- ; https://uqfoundation.github.io/project/pathos
Please see https://uqfoundation.github.io/project/pathos or http://arxiv.org/pdf/1202.1056 for further information.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
File details
Details for the file multiprocess-0.70.17.tar.gz
.
File metadata
- Download URL: multiprocess-0.70.17.tar.gz
- Upload date:
- Size: 1.8 MB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.13.0rc2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4ae2f11a3416809ebc9a48abfc8b14ecce0652a0944731a1493a3c1ba44ff57a |
|
MD5 | 25990efb2cc669639df2535425c9193a |
|
BLAKE2b-256 | e9341acca6e18697017ad5c8b45279b59305d660ecf2fbed13e5f406f69890e4 |
File details
Details for the file multiprocess-0.70.17-py313-none-any.whl
.
File metadata
- Download URL: multiprocess-0.70.17-py313-none-any.whl
- Upload date:
- Size: 149.8 kB
- Tags: Python 3.13
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.13.0rc2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 20c28ca19079a6c879258103a6d60b94d4ffe2d9da07dda93fb1c8bc6243f522 |
|
MD5 | b921e0f51f378369030bb72ec374fc0c |
|
BLAKE2b-256 | c8b72e9a4fcd871b81e1f2a812cd5c6fb52ad1e8da7bf0d7646c55eaae220484 |
File details
Details for the file multiprocess-0.70.17-py312-none-any.whl
.
File metadata
- Download URL: multiprocess-0.70.17-py312-none-any.whl
- Upload date:
- Size: 148.0 kB
- Tags: Python 3.12
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.13.0rc2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2818af14c52446b9617d1b0755fa70ca2f77c28b25ed97bdaa2c69a22c47b46c |
|
MD5 | 239e414db63e1a088895d5c4acc12f9c |
|
BLAKE2b-256 | a469d3f343a61a2f86ef10ed7865a26beda7c71554136ce187b0384b1c2c9ca3 |
File details
Details for the file multiprocess-0.70.17-py311-none-any.whl
.
File metadata
- Download URL: multiprocess-0.70.17-py311-none-any.whl
- Upload date:
- Size: 144.3 kB
- Tags: Python 3.11
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.13.0rc2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2884701445d0177aec5bd5f6ee0df296773e4fb65b11903b94c613fb46cfb7d1 |
|
MD5 | 1eeaf7b155d27baedba4502403cd9b5d |
|
BLAKE2b-256 | b2078cbb75d6cfbe8712d8f7f6a5615f083c6e710ab916b748fbb20373ddb142 |
File details
Details for the file multiprocess-0.70.17-py310-none-any.whl
.
File metadata
- Download URL: multiprocess-0.70.17-py310-none-any.whl
- Upload date:
- Size: 134.8 kB
- Tags: Python 3.10
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.13.0rc2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 38357ca266b51a2e22841b755d9a91e4bb7b937979a54d411677111716c32744 |
|
MD5 | 1cdc0bae6a5c7f38a58cc2fbe03746a1 |
|
BLAKE2b-256 | e7a939cf856d03690af6fd570cf40331f1f79acdbb3132a9c35d2c5002f7f30b |
File details
Details for the file multiprocess-0.70.17-py39-none-any.whl
.
File metadata
- Download URL: multiprocess-0.70.17-py39-none-any.whl
- Upload date:
- Size: 133.4 kB
- Tags: Python 3.9
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.13.0rc2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | c3feb874ba574fbccfb335980020c1ac631fbf2a3f7bee4e2042ede62558a021 |
|
MD5 | 7db43aaa13a93e5a0dc6cad7caf6ee0f |
|
BLAKE2b-256 | f9410618ac724b8a56254962c143759e04fa01c73b37aa69dd433f16643bd38b |
File details
Details for the file multiprocess-0.70.17-py38-none-any.whl
.
File metadata
- Download URL: multiprocess-0.70.17-py38-none-any.whl
- Upload date:
- Size: 132.6 kB
- Tags: Python 3.8
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.13.0rc2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1d52f068357acd1e5bbc670b273ef8f81d57863235d9fbf9314751886e141968 |
|
MD5 | 56bfd4352e2526a2491786437cefdbae |
|
BLAKE2b-256 | aed7fd7a092fc0ab1845a1a97ca88e61b9b7cc2e9d6fcf0ed24e9480590c2336 |
File details
Details for the file multiprocess-0.70.17-pp310-pypy310_pp73-manylinux_2_28_x86_64.whl
.
File metadata
- Download URL: multiprocess-0.70.17-pp310-pypy310_pp73-manylinux_2_28_x86_64.whl
- Upload date:
- Size: 135.0 kB
- Tags: PyPy, manylinux: glibc 2.28+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.13.0rc2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | c2c82d0375baed8d8dd0d8c38eb87c5ae9c471f8e384ad203a36f095ee860f67 |
|
MD5 | 3bc09e2d9c2bf4c53bc9a289bd6d838f |
|
BLAKE2b-256 | 20e3db48b10f0a25569c5c3a20288d82f9677cb312bccbd1da16cf8fb759649f |
File details
Details for the file multiprocess-0.70.17-pp310-pypy310_pp73-macosx_11_0_arm64.whl
.
File metadata
- Download URL: multiprocess-0.70.17-pp310-pypy310_pp73-macosx_11_0_arm64.whl
- Upload date:
- Size: 135.0 kB
- Tags: PyPy, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.13.0rc2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | d729f55198a3579f6879766a6d9b72b42d4b320c0dcb7844afb774d75b573c62 |
|
MD5 | b7116987ac38c0d35b5b3b7b3bd120cc |
|
BLAKE2b-256 | 8f0abb06ea45e5b400cd9944e05878fdbb9016ba78ffb9190c541eec9c8e8380 |
File details
Details for the file multiprocess-0.70.17-pp310-pypy310_pp73-macosx_10_15_x86_64.whl
.
File metadata
- Download URL: multiprocess-0.70.17-pp310-pypy310_pp73-macosx_10_15_x86_64.whl
- Upload date:
- Size: 135.0 kB
- Tags: PyPy, macOS 10.15+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.13.0rc2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7ddb24e5bcdb64e90ec5543a1f05a39463068b6d3b804aa3f2a4e16ec28562d6 |
|
MD5 | 11f74243bd3b53dde9712d51a4f5e77b |
|
BLAKE2b-256 | f297e57eaa8a4dc4036460d13162470eb0da520e6496a90b943529cf1ca40ebd |
File details
Details for the file multiprocess-0.70.17-pp39-pypy39_pp73-manylinux_2_28_x86_64.whl
.
File metadata
- Download URL: multiprocess-0.70.17-pp39-pypy39_pp73-manylinux_2_28_x86_64.whl
- Upload date:
- Size: 133.5 kB
- Tags: PyPy, manylinux: glibc 2.28+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.13.0rc2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | a0f01cd9d079af7a8296f521dc03859d1a414d14c1e2b6e676ef789333421c95 |
|
MD5 | 45a0f9138eebc321020e59b94a845fc3 |
|
BLAKE2b-256 | d6beefe661a064d9348bcc4a21bcdb6c8c02a2ab61ec337a70fbdeaeb75693e0 |
File details
Details for the file multiprocess-0.70.17-pp39-pypy39_pp73-macosx_10_13_x86_64.whl
.
File metadata
- Download URL: multiprocess-0.70.17-pp39-pypy39_pp73-macosx_10_13_x86_64.whl
- Upload date:
- Size: 133.5 kB
- Tags: PyPy, macOS 10.13+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.13.0rc2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2b12e081df87ab755190e227341b2c3b17ee6587e9c82fecddcbe6aa812cd7f7 |
|
MD5 | 80cfb83cd3a5c5c109e9dcc6777fb81e |
|
BLAKE2b-256 | 127359682eecafc2c7880141a7b9c0cf65d6491ffd67a2a8453396976f2a4f33 |
File details
Details for the file multiprocess-0.70.17-pp39-pypy39_pp73-macosx_10_13_arm64.whl
.
File metadata
- Download URL: multiprocess-0.70.17-pp39-pypy39_pp73-macosx_10_13_arm64.whl
- Upload date:
- Size: 133.5 kB
- Tags: PyPy, macOS 10.13+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.13.0rc2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2ea0939b0f4760a16a548942c65c76ff5afd81fbf1083c56ae75e21faf92e426 |
|
MD5 | c06fdbe100f5c61903adbe8b27a8cc2e |
|
BLAKE2b-256 | 60a13359dd7d4ecee40ce05f952bef3737075d0d1cccab04b59e732dac26534c |
File details
Details for the file multiprocess-0.70.17-pp38-pypy38_pp73-manylinux_2_28_x86_64.whl
.
File metadata
- Download URL: multiprocess-0.70.17-pp38-pypy38_pp73-manylinux_2_28_x86_64.whl
- Upload date:
- Size: 135.1 kB
- Tags: PyPy, manylinux: glibc 2.28+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.13.0rc2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 27b8409c02b5dd89d336107c101dfbd1530a2cd4fd425fc27dcb7adb6e0b47bf |
|
MD5 | aaa4ad26bcb7eeff7ad04d2e0c1659bf |
|
BLAKE2b-256 | c1bcf85768d4d9889219e69aae5c94c333a2e56c9929befc941d3206648194b9 |
File details
Details for the file multiprocess-0.70.17-pp38-pypy38_pp73-macosx_10_9_x86_64.whl
.
File metadata
- Download URL: multiprocess-0.70.17-pp38-pypy38_pp73-macosx_10_9_x86_64.whl
- Upload date:
- Size: 132.8 kB
- Tags: PyPy, macOS 10.9+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.13.0rc2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 349525099a0c9ac5936f0488b5ee73199098dac3ac899d81d326d238f9fd3ccd |
|
MD5 | 37a8a480fca19b0f810d120eb8ae4b60 |
|
BLAKE2b-256 | 38f067f2ae380115f43e8f2cb04bcd7d784841ee485be4ba98d88425d5e02e26 |
File details
Details for the file multiprocess-0.70.17-pp38-pypy38_pp73-macosx_10_9_arm64.whl
.
File metadata
- Download URL: multiprocess-0.70.17-pp38-pypy38_pp73-macosx_10_9_arm64.whl
- Upload date:
- Size: 132.8 kB
- Tags: PyPy, macOS 10.9+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.13.0rc2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | a22a6b1a482b80eab53078418bb0f7025e4f7d93cc8e1f36481477a023884861 |
|
MD5 | 8ff34c6d4c55b1bd105e9fc29ab68018 |
|
BLAKE2b-256 | 2924a0be32891f474f58adb1f732c6c7e1eb68d932920168a517a3939c7193ea |