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

  • setuptools, >=42

  • dill, >=0.4.1

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


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.19.tar.gz (2.1 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.19-py314-none-any.whl (160.3 kB view details)

Uploaded Python 3.14

multiprocess-0.70.19-py313-none-any.whl (156.4 kB view details)

Uploaded Python 3.13

multiprocess-0.70.19-py312-none-any.whl (150.3 kB view details)

Uploaded Python 3.12

multiprocess-0.70.19-py311-none-any.whl (144.5 kB view details)

Uploaded Python 3.11

multiprocess-0.70.19-py310-none-any.whl (134.9 kB view details)

Uploaded Python 3.10

multiprocess-0.70.19-py39-none-any.whl (133.5 kB view details)

Uploaded Python 3.9

multiprocess-0.70.19-pp311-pypy311_pp73-manylinux_2_28_x86_64.whl (144.7 kB view details)

Uploaded PyPymanylinux: glibc 2.28+ x86-64

multiprocess-0.70.19-pp311-pypy311_pp73-macosx_11_0_arm64.whl (144.7 kB view details)

Uploaded PyPymacOS 11.0+ ARM64

multiprocess-0.70.19-pp311-pypy311_pp73-macosx_10_15_x86_64.whl (144.7 kB view details)

Uploaded PyPymacOS 10.15+ x86-64

multiprocess-0.70.19-pp310-pypy310_pp73-manylinux_2_28_x86_64.whl (135.1 kB view details)

Uploaded PyPymanylinux: glibc 2.28+ x86-64

multiprocess-0.70.19-pp310-pypy310_pp73-macosx_11_0_arm64.whl (135.1 kB view details)

Uploaded PyPymacOS 11.0+ ARM64

multiprocess-0.70.19-pp310-pypy310_pp73-macosx_10_15_x86_64.whl (135.1 kB view details)

Uploaded PyPymacOS 10.15+ x86-64

multiprocess-0.70.19-pp39-pypy39_pp73-manylinux_2_28_x86_64.whl (133.5 kB view details)

Uploaded PyPymanylinux: glibc 2.28+ x86-64

multiprocess-0.70.19-pp39-pypy39_pp73-macosx_10_13_x86_64.whl (133.7 kB view details)

Uploaded PyPymacOS 10.13+ x86-64

multiprocess-0.70.19-pp39-pypy39_pp73-macosx_10_13_arm64.whl (133.5 kB view details)

Uploaded PyPymacOS 10.13+ ARM64

File details

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

File metadata

  • Download URL: multiprocess-0.70.19.tar.gz
  • Upload date:
  • Size: 2.1 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.13.11

File hashes

Hashes for multiprocess-0.70.19.tar.gz
Algorithm Hash digest
SHA256 952021e0e6c55a4a9fe4cd787895b86e239a40e76802a789d6305398d3975897
MD5 07baa5dfc52b30e5fab24ad4f6120808
BLAKE2b-256 a2f2e783ac7f2aeeed14e9e12801f22529cc7e6b7ab80928d6dcce4e9f00922d

See more details on using hashes here.

File details

Details for the file multiprocess-0.70.19-py314-none-any.whl.

File metadata

File hashes

Hashes for multiprocess-0.70.19-py314-none-any.whl
Algorithm Hash digest
SHA256 e8cc7fbdff15c0613f0a1f1f8744bef961b0a164c0ca29bdff53e9d2d93c5e5f
MD5 5cdceee2ce23b83a1c66d74390fa633c
BLAKE2b-256 a061af9115673a5870fd885247e2f1b68c4f1197737da315b520a91c757a861a

See more details on using hashes here.

File details

Details for the file multiprocess-0.70.19-py313-none-any.whl.

File metadata

File hashes

Hashes for multiprocess-0.70.19-py313-none-any.whl
Algorithm Hash digest
SHA256 8d5eb4ec5017ba2fab4e34a747c6d2c2b6fecfe9e7236e77988db91580ada952
MD5 be496e82743cce3a1e04c054458cf978
BLAKE2b-256 7f74d2c27e03cb84251dfe7249b8e82923643c6d48fa4883b9476b025e7dc7eb

See more details on using hashes here.

File details

Details for the file multiprocess-0.70.19-py312-none-any.whl.

File metadata

File hashes

Hashes for multiprocess-0.70.19-py312-none-any.whl
Algorithm Hash digest
SHA256 3a56c0e85dd5025161bac5ce138dcac1e49174c7d8e74596537e729fd5c53c28
MD5 edb6934395355ea8b1c06afd042c3670
BLAKE2b-256 717038998b950a97ea279e6bd657575d22d1a2047256caf707d9a10fbce4f065

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for multiprocess-0.70.19-py311-none-any.whl
Algorithm Hash digest
SHA256 928851ae7973aea4ce0eaf330bbdafb2e01398a91518d5c8818802845564f45c
MD5 d7801f7e4f2d1a56a0fca84565a60023
BLAKE2b-256 86c2dec9722dc3474c164a0b6bcd9a7ed7da542c98af8cabce05374abab35edd

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for multiprocess-0.70.19-py310-none-any.whl
Algorithm Hash digest
SHA256 97404393419dcb2a8385910864eedf47a3cadf82c66345b44f036420eb0b5d87
MD5 f3ccf1326375bbaa1c1d0e1689bb70e9
BLAKE2b-256 e3458004d1e6b9185c1a444d6b55ac5682acf9d98035e54386d967366035a03a

See more details on using hashes here.

File details

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

File metadata

  • Download URL: multiprocess-0.70.19-py39-none-any.whl
  • Upload date:
  • Size: 133.5 kB
  • Tags: Python 3.9
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.13.11

File hashes

Hashes for multiprocess-0.70.19-py39-none-any.whl
Algorithm Hash digest
SHA256 0d4b4397ed669d371c81dcd1ef33fd384a44d6c3de1bd0ca7ac06d837720d3c5
MD5 869eac05215d379d98ba5a4f757ec0c9
BLAKE2b-256 7e8269e539c4c2027f1e1697e09aaa2449243085a0edf81ae2c6341e84d769b6

See more details on using hashes here.

File details

Details for the file multiprocess-0.70.19-pp311-pypy311_pp73-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for multiprocess-0.70.19-pp311-pypy311_pp73-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 1c3dce098845a0db43b32a0b76a228ca059a668071cfeaa0f40c36c0b1585d45
MD5 4a117d6383bcc64601c68b16afe51ad0
BLAKE2b-256 afcbf421c2869d75750a4f32301cc20c4b63fab6376e9a75c8e5e655bdeb3d9b

See more details on using hashes here.

File details

Details for the file multiprocess-0.70.19-pp311-pypy311_pp73-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for multiprocess-0.70.19-pp311-pypy311_pp73-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 5be9ec7f0c1c49a4f4a6fd20d5dda4aeabc2d39a50f4ad53720f1cd02b3a7c2e
MD5 ed3910a8f43b96b878e79c41e83ce46e
BLAKE2b-256 0fe1155f6abf5e6b5d9cef29b6d0167c180846157a4aca9b9bee1a217f67c959

See more details on using hashes here.

File details

Details for the file multiprocess-0.70.19-pp311-pypy311_pp73-macosx_10_15_x86_64.whl.

File metadata

File hashes

Hashes for multiprocess-0.70.19-pp311-pypy311_pp73-macosx_10_15_x86_64.whl
Algorithm Hash digest
SHA256 1bbf1b69af1cf64cd05f65337d9215b88079ec819cd0ea7bac4dab84e162efe7
MD5 f32d8d513a5d757da463238064cd1528
BLAKE2b-256 7eaa714635c727dbfc251139226fa4eaf1b07f00dc12d9cd2eb25f931adaf873

See more details on using hashes here.

File details

Details for the file multiprocess-0.70.19-pp310-pypy310_pp73-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for multiprocess-0.70.19-pp310-pypy310_pp73-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 c6b6d78d43a03b68014ca1f0b7937d965393a670c5de7c29026beb2258f2f896
MD5 d7599fe9d131736e29fe8fbd2310544e
BLAKE2b-256 94b10b71d18b76bf423c2e8ee00b31db37d17297ab3b4db44e188692afdca628

See more details on using hashes here.

File details

Details for the file multiprocess-0.70.19-pp310-pypy310_pp73-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for multiprocess-0.70.19-pp310-pypy310_pp73-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 79576c02d1207ec405b00cabf2c643c36070800cca433860e14539df7818b2aa
MD5 ce273135504e4542dc133bea5fa2ab49
BLAKE2b-256 9950faef2d8106534b0dc4a0b772668a1a99682696ebf17d3c0f13f2ed6a656a

See more details on using hashes here.

File details

Details for the file multiprocess-0.70.19-pp310-pypy310_pp73-macosx_10_15_x86_64.whl.

File metadata

File hashes

Hashes for multiprocess-0.70.19-pp310-pypy310_pp73-macosx_10_15_x86_64.whl
Algorithm Hash digest
SHA256 02e5c35d7d6cd2bdc89c1858867f7bde4012837411023a4696c148c1bdd7c80e
MD5 012f74ac0eb6bec6d6506e764360022b
BLAKE2b-256 8bb610832f96b499690854e574360be342a282f5f7dba58eff791299ff6c0637

See more details on using hashes here.

File details

Details for the file multiprocess-0.70.19-pp39-pypy39_pp73-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for multiprocess-0.70.19-pp39-pypy39_pp73-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 d6db91ca6391eebc139c352f34578cea382df6bfa03d3b4146ed12b18b01cc14
MD5 39bc8a838b9874fdf50dfe1d08e9f89c
BLAKE2b-256 4edba5fcaad04fb7b2e1c043df6f00d2a34ba88861ef5eeb11b82a3c80f813bd

See more details on using hashes here.

File details

Details for the file multiprocess-0.70.19-pp39-pypy39_pp73-macosx_10_13_x86_64.whl.

File metadata

File hashes

Hashes for multiprocess-0.70.19-pp39-pypy39_pp73-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 e6c0674d34b8adac22533f6786576b3de4e396aaeda9e0c15378af9b8ada2702
MD5 f6337b927e8fdfde0ebb96bf23efb095
BLAKE2b-256 d0756e4fc33200ff67819b234150c594193109f4a4573106ee4e0f417b6f6e44

See more details on using hashes here.

File details

Details for the file multiprocess-0.70.19-pp39-pypy39_pp73-macosx_10_13_arm64.whl.

File metadata

File hashes

Hashes for multiprocess-0.70.19-pp39-pypy39_pp73-macosx_10_13_arm64.whl
Algorithm Hash digest
SHA256 e5e7dc3e3e1732e88c07aaec17eeb9917f9ed1107d9e60d5ab985cdc14bac43a
MD5 9772cd5b4fccaf64a7bb8a3715889351
BLAKE2b-256 41abccd9652d32e79f8fc4235f64fbfb39c85583c96f4c2290ff7757cf213ccb

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