Skip to main content

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:

https://pypi.org/project/multiprocess

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:

https://github.com/uqfoundation

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.7

  • setuptools, >=42

  • dill, >=0.3.7

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.11/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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

multiprocess-0.70.15.tar.gz (1.9 MB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

multiprocess-0.70.15-py311-none-any.whl (135.4 kB view details)

Uploaded Python 3.11

multiprocess-0.70.15-py310-none-any.whl (134.8 kB view details)

Uploaded Python 3.10

multiprocess-0.70.15-py39-none-any.whl (133.3 kB view details)

Uploaded Python 3.9

multiprocess-0.70.15-py38-none-any.whl (132.6 kB view details)

Uploaded Python 3.8

multiprocess-0.70.15-py37-none-any.whl (116.3 kB view details)

Uploaded Python 3.7

multiprocess-0.70.15-pp310-pypy310_pp73-macosx_10_9_x86_64.whl (135.0 kB view details)

Uploaded PyPymacOS 10.9+ x86-64

multiprocess-0.70.15-pp39-pypy39_pp73-manylinux_2_24_x86_64.whl (133.5 kB view details)

Uploaded PyPymanylinux: glibc 2.24+ x86-64

multiprocess-0.70.15-pp39-pypy39_pp73-manylinux_2_24_i686.whl (133.5 kB view details)

Uploaded PyPymanylinux: glibc 2.24+ i686

multiprocess-0.70.15-pp39-pypy39_pp73-macosx_10_9_x86_64.whl (133.5 kB view details)

Uploaded PyPymacOS 10.9+ x86-64

multiprocess-0.70.15-pp38-pypy38_pp73-manylinux_2_24_x86_64.whl (132.8 kB view details)

Uploaded PyPymanylinux: glibc 2.24+ x86-64

multiprocess-0.70.15-pp38-pypy38_pp73-manylinux_2_24_i686.whl (132.8 kB view details)

Uploaded PyPymanylinux: glibc 2.24+ i686

multiprocess-0.70.15-pp38-pypy38_pp73-macosx_10_9_x86_64.whl (132.8 kB view details)

Uploaded PyPymacOS 10.9+ x86-64

multiprocess-0.70.15-pp37-pypy37_pp73-manylinux_2_24_x86_64.whl (116.4 kB view details)

Uploaded PyPymanylinux: glibc 2.24+ x86-64

multiprocess-0.70.15-pp37-pypy37_pp73-manylinux_2_24_i686.whl (116.4 kB view details)

Uploaded PyPymanylinux: glibc 2.24+ i686

multiprocess-0.70.15-pp37-pypy37_pp73-macosx_10_9_x86_64.whl (116.4 kB view details)

Uploaded PyPymacOS 10.9+ x86-64

File details

Details for the file multiprocess-0.70.15.tar.gz.

File metadata

  • Download URL: multiprocess-0.70.15.tar.gz
  • Upload date:
  • Size: 1.9 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.12.0b3

File hashes

Hashes for multiprocess-0.70.15.tar.gz
Algorithm Hash digest
SHA256 f20eed3036c0ef477b07a4177cf7c1ba520d9a2677870a4f47fe026f0cd6787e
MD5 1bd2721affbe49a45624dda97241f8bc
BLAKE2b-256 68e0a77ca96e772e13c828fa52f3ad370d413bef194aeaf78b7c6611870ad815

See more details on using hashes here.

File details

Details for the file multiprocess-0.70.15-py311-none-any.whl.

File metadata

  • Download URL: multiprocess-0.70.15-py311-none-any.whl
  • Upload date:
  • Size: 135.4 kB
  • Tags: Python 3.11
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.12.0b3

File hashes

Hashes for multiprocess-0.70.15-py311-none-any.whl
Algorithm Hash digest
SHA256 134f89053d82c9ed3b73edd3a2531eb791e602d4f4156fc92a79259590bd9670
MD5 7b17766b3bc0dcd456fbe82d5c3c70e8
BLAKE2b-256 e74196ac938770ba6e7d5ae1d8c9cafebac54b413549042c6260f0d0a6ec6622

See more details on using hashes here.

File details

Details for the file multiprocess-0.70.15-py310-none-any.whl.

File metadata

  • Download URL: multiprocess-0.70.15-py310-none-any.whl
  • Upload date:
  • Size: 134.8 kB
  • Tags: Python 3.10
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.12.0b3

File hashes

Hashes for multiprocess-0.70.15-py310-none-any.whl
Algorithm Hash digest
SHA256 7dd58e33235e83cf09d625e55cffd7b0f0eede7ee9223cdd666a87624f60c21a
MD5 edf6980adf1a93fa803666af890025d9
BLAKE2b-256 35a836d8d7b3e46b377800d8dec47891cdf05842d1a2366909ae4a0c89fbc5e6

See more details on using hashes here.

File details

Details for the file multiprocess-0.70.15-py39-none-any.whl.

File metadata

  • Download URL: multiprocess-0.70.15-py39-none-any.whl
  • Upload date:
  • Size: 133.3 kB
  • Tags: Python 3.9
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.12.0b3

File hashes

Hashes for multiprocess-0.70.15-py39-none-any.whl
Algorithm Hash digest
SHA256 3e0953f5d52b4c76f1c973eaf8214554d146f2be5decb48e928e55c7a2d19338
MD5 89687899da0ab828df18f4d5609af648
BLAKE2b-256 c6c9820b5ab056f4ada76fbe05bd481a948f287957d6cbfd59e2dd2618b408c1

See more details on using hashes here.

File details

Details for the file multiprocess-0.70.15-py38-none-any.whl.

File metadata

  • Download URL: multiprocess-0.70.15-py38-none-any.whl
  • Upload date:
  • Size: 132.6 kB
  • Tags: Python 3.8
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.12.0b3

File hashes

Hashes for multiprocess-0.70.15-py38-none-any.whl
Algorithm Hash digest
SHA256 bee9afba476c91f9ebee7beeee0601face9eff67d822e893f9a893725fbd6316
MD5 cede2eb7c6e37f5f459cd3939fc0731d
BLAKE2b-256 c2a6c5cb599d917904878f220a4dbdfdcc4ef291dd3956c35b3b0dc6fc42fb6d

See more details on using hashes here.

File details

Details for the file multiprocess-0.70.15-py37-none-any.whl.

File metadata

  • Download URL: multiprocess-0.70.15-py37-none-any.whl
  • Upload date:
  • Size: 116.3 kB
  • Tags: Python 3.7
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.12.0b3

File hashes

Hashes for multiprocess-0.70.15-py37-none-any.whl
Algorithm Hash digest
SHA256 f7d4a1629bccb433114c3b4885f69eccc200994323c80f6feee73b0edc9199c5
MD5 ec03c75beebe4a02d0731f61cd5cfdb0
BLAKE2b-256 ca3f8354ce12fd13bd5c5bb4722261a10ca1d6e2eb7c1c08fa3d8a4e9dc98f44

See more details on using hashes here.

File details

Details for the file multiprocess-0.70.15-pp310-pypy310_pp73-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for multiprocess-0.70.15-pp310-pypy310_pp73-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 aa36c7ed16f508091438687fe9baa393a7a8e206731d321e443745e743a0d4e5
MD5 209afc93c7b2a7b374871dca7c6c005a
BLAKE2b-256 36733dcd3175c0295d3989859197c8a9111d5936693a0ea639dc80de87bb7803

See more details on using hashes here.

File details

Details for the file multiprocess-0.70.15-pp39-pypy39_pp73-manylinux_2_24_x86_64.whl.

File metadata

File hashes

Hashes for multiprocess-0.70.15-pp39-pypy39_pp73-manylinux_2_24_x86_64.whl
Algorithm Hash digest
SHA256 1a51dd34096db47fb21fa2b839e615b051d51b97af9a67afbcdaa67186b44883
MD5 d76ee94a2e7a0ca67dd4a16feb176f90
BLAKE2b-256 71475d12db2427465486c0b336cc67753e8826b756a2e4d4ef6385f4f01b355b

See more details on using hashes here.

File details

Details for the file multiprocess-0.70.15-pp39-pypy39_pp73-manylinux_2_24_i686.whl.

File metadata

File hashes

Hashes for multiprocess-0.70.15-pp39-pypy39_pp73-manylinux_2_24_i686.whl
Algorithm Hash digest
SHA256 0eac53214d664c49a34695e5824872db4006b1a465edd7459a251809c3773370
MD5 5caf8667c994a46062dc2d54b3fd3a72
BLAKE2b-256 839708402e5ec72c1cc461df1f2e654c1e55527bb05c22120dcdf59745189df6

See more details on using hashes here.

File details

Details for the file multiprocess-0.70.15-pp39-pypy39_pp73-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for multiprocess-0.70.15-pp39-pypy39_pp73-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 18f9f2c7063346d1617bd1684fdcae8d33380ae96b99427260f562e1a1228b67
MD5 502841b0e0a22d0301f932391c8df196
BLAKE2b-256 7b5686312ddac225d6fba16ec1af772bab7c8c9845fe11063c7492fdb1e9be04

See more details on using hashes here.

File details

Details for the file multiprocess-0.70.15-pp38-pypy38_pp73-manylinux_2_24_x86_64.whl.

File metadata

File hashes

Hashes for multiprocess-0.70.15-pp38-pypy38_pp73-manylinux_2_24_x86_64.whl
Algorithm Hash digest
SHA256 cf981fb998d6ec3208cb14f0cf2e9e80216e834f5d51fd09ebc937c32b960902
MD5 e3a8e9ff5c0f4898087b60dbb78430e3
BLAKE2b-256 648486590899265e02120ca435f415221af2ead750cfb468b91829e2088fa844

See more details on using hashes here.

File details

Details for the file multiprocess-0.70.15-pp38-pypy38_pp73-manylinux_2_24_i686.whl.

File metadata

File hashes

Hashes for multiprocess-0.70.15-pp38-pypy38_pp73-manylinux_2_24_i686.whl
Algorithm Hash digest
SHA256 4271647bd8a49c28ecd6eb56a7fdbd3c212c45529ad5303b40b3c65fc6928e5f
MD5 dfed30d0a1bca30ae3fbdec7f02d6aec
BLAKE2b-256 d919fd4b34b7ca6561424d4fec063ae50ecd2517bf6a5627044fe74a70fe2b8b

See more details on using hashes here.

File details

Details for the file multiprocess-0.70.15-pp38-pypy38_pp73-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for multiprocess-0.70.15-pp38-pypy38_pp73-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 73db2e7b32dcc7f9b0f075c2ffa45c90b6729d3f1805f27e88534c8d321a1be5
MD5 f9079f8ad561f08212f37db9aeaff244
BLAKE2b-256 7425aedbe24da8855bf77fa3b220843c67c8036af970fe298a96f1e73e2c757a

See more details on using hashes here.

File details

Details for the file multiprocess-0.70.15-pp37-pypy37_pp73-manylinux_2_24_x86_64.whl.

File metadata

File hashes

Hashes for multiprocess-0.70.15-pp37-pypy37_pp73-manylinux_2_24_x86_64.whl
Algorithm Hash digest
SHA256 e73f497e6696a0f5433ada2b3d599ae733b87a6e8b008e387c62ac9127add177
MD5 8c76129b2dc692f5a2a9d81cce0c2519
BLAKE2b-256 c6875b60dc95f970d1247ab049acb42acab0146ef29a96837de5edd29a74cc10

See more details on using hashes here.

File details

Details for the file multiprocess-0.70.15-pp37-pypy37_pp73-manylinux_2_24_i686.whl.

File metadata

File hashes

Hashes for multiprocess-0.70.15-pp37-pypy37_pp73-manylinux_2_24_i686.whl
Algorithm Hash digest
SHA256 e576062981c91f0fe8a463c3d52506e598dfc51320a8dd8d78b987dfca91c5db
MD5 a6e6433256af3871d082157f35802bb8
BLAKE2b-256 33b15101fb55d499810fde73fba93733cec84b19ebcd8f0cec70f625eafaba8a

See more details on using hashes here.

File details

Details for the file multiprocess-0.70.15-pp37-pypy37_pp73-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for multiprocess-0.70.15-pp37-pypy37_pp73-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 20e024018c46d0d1602024c613007ac948f9754659e3853b0aa705e83f6931d8
MD5 750ba1795cfb8251accdad970dafa7de
BLAKE2b-256 42e06de4f04d8b8b1b63d3df5d1af166fe130f18141eb79280d43becb5bb4977

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page