Skip to main content

better multiprocessing and multithreading in python

Project description

About Multiprocess

multiprocess is a fork of multiprocessing, and is developed as part of pathos: https://github.com/uqfoundation/pathos

multiprocessing is a package for the Python language which supports the spawning of processes using the API of the standard library’s threading module. multiprocessing has been distributed in the standard library since python 2.6.

Features:

  • Objects can be transferred between processes using pipes or multi-producer/multi-consumer queues.

  • Objects can be shared between processes using a server process or (for simple data) shared memory.

  • Equivalents of all the synchronization primitives in threading are available.

  • A Pool class makes it easy to submit tasks to a pool of worker processes.

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.

NOTE: A C compiler is required to build the included extension module. For python 3.3 and above, a C compiler is suggested, but not required.

Major Changes

  • enhanced serialization, using dill

Current Release

This documentation is for version multiprocess-0.70.12.2 (a fork of multiprocessing-0.70a1).

The latest released version of multiprocess is available from:

https://pypi.org/project/multiprocess

Multiprocessing is distributed under a BSD license.

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 is packaged to install from source, so you must download the tarball, unzip, and run the installer:

[download]
$ tar -xvzf multiprocess-0.70.12.2.tgz
$ cd multiprocess-0.70.12.2
$ python setup.py build
$ python setup.py install

You will be warned of any missing dependencies and/or settings after you run the “build” step above.

Alternately, multiprocess can be installed with pip or easy_install:

$ pip install multiprocess

NOTE: A C compiler is required to build the included extension module from source. For python 3.3 and above, a C compiler is suggested, but not required. Binary installs do not require a C compiler.

Requirements

multiprocess requires:

- ``python``, **version == 2.7** or **version >= 3.6**, or ``pypy``
- ``dill``, **version >= 0.3.4**

Optional requirements:

- ``setuptools``, **version >= 0.6**

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. See multiprocess.examples for a set of example scripts. You can also run the test suite with python -m multiprocess.tests. 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 post 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.12.2.zip (3.3 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.12.2-py39-none-any.whl (128.7 kB view details)

Uploaded Python 3.9

multiprocess-0.70.12.2-py38-none-any.whl (128.3 kB view details)

Uploaded Python 3.8

multiprocess-0.70.12.2-py37-none-any.whl (112.1 kB view details)

Uploaded Python 3.7

multiprocess-0.70.12.2-py36-none-any.whl (107.0 kB view details)

Uploaded Python 3.6

multiprocess-0.70.12.2-pp37-none-any.whl (112.2 kB view details)

Uploaded PyPy

multiprocess-0.70.12.2-pp36-none-any.whl (105.9 kB view details)

Uploaded PyPy

multiprocess-0.70.12.2-pp27-none-any.whl (82.0 kB view details)

Uploaded PyPy

multiprocess-0.70.12.2-cp27-cp27m-win_amd64.whl (93.3 kB view details)

Uploaded CPython 2.7mWindows x86-64

multiprocess-0.70.12.2-cp27-cp27m-win32.whl (92.3 kB view details)

Uploaded CPython 2.7mWindows x86

multiprocess-0.70.12.2-cp27-cp27m-manylinux1_x86_64.whl (118.8 kB view details)

Uploaded CPython 2.7m

multiprocess-0.70.12.2-cp27-cp27m-manylinux1_i686.whl (116.2 kB view details)

Uploaded CPython 2.7m

multiprocess-0.70.12.2-cp27-cp27m-macosx_10_12_x86_64.whl (90.4 kB view details)

Uploaded CPython 2.7mmacOS 10.12+ x86-64

File details

Details for the file multiprocess-0.70.12.2.zip.

File metadata

  • Download URL: multiprocess-0.70.12.2.zip
  • Upload date:
  • Size: 3.3 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.5.0.1 requests/2.21.0 setuptools/56.1.0 requests-toolbelt/0.8.0 tqdm/4.29.1 CPython/3.6.13

File hashes

Hashes for multiprocess-0.70.12.2.zip
Algorithm Hash digest
SHA256 206bb9b97b73f87fec1ed15a19f8762950256aa84225450abc7150d02855a083
MD5 3aa66ca9da9a198161ad1c11fccc2225
BLAKE2b-256 991a472900644359cdd208d1fbe71706bdeecbc6e8db2e39c35ebe89459e9172

See more details on using hashes here.

File details

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

File metadata

  • Download URL: multiprocess-0.70.12.2-py39-none-any.whl
  • Upload date:
  • Size: 128.7 kB
  • Tags: Python 3.9
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.5.0.1 requests/2.21.0 setuptools/56.1.0 requests-toolbelt/0.8.0 tqdm/4.29.1 CPython/3.6.13

File hashes

Hashes for multiprocess-0.70.12.2-py39-none-any.whl
Algorithm Hash digest
SHA256 6f812a1d3f198b7cacd63983f60e2dc1338bd4450893f90c435067b5a3127e6f
MD5 4be647a46fdc7a5efa52c3bcc9201883
BLAKE2b-256 e312c1c7b5574a574a5bc898c8656b0ab8514d0609356b3ca18180e2ae94c2f7

See more details on using hashes here.

File details

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

File metadata

  • Download URL: multiprocess-0.70.12.2-py38-none-any.whl
  • Upload date:
  • Size: 128.3 kB
  • Tags: Python 3.8
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.5.0.1 requests/2.21.0 setuptools/56.1.0 requests-toolbelt/0.8.0 tqdm/4.29.1 CPython/3.6.13

File hashes

Hashes for multiprocess-0.70.12.2-py38-none-any.whl
Algorithm Hash digest
SHA256 85941e650c277af44fc82e3e97faacb920e5ce3615238b540cbad4012d6f60e9
MD5 d134c73326e429d6c623dac29eaf8a40
BLAKE2b-256 e622b09b8394f8c86ff0cfebd725ea96bba0accd4a4b2be437bcba6a0cf7d1c3

See more details on using hashes here.

File details

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

File metadata

  • Download URL: multiprocess-0.70.12.2-py37-none-any.whl
  • Upload date:
  • Size: 112.1 kB
  • Tags: Python 3.7
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.5.0.1 requests/2.21.0 setuptools/56.1.0 requests-toolbelt/0.8.0 tqdm/4.29.1 CPython/3.6.13

File hashes

Hashes for multiprocess-0.70.12.2-py37-none-any.whl
Algorithm Hash digest
SHA256 6aa67e805e50b6e9dfc56dd0f0c85ac3409e6791d4ec5405c5f9bc0a47d745a4
MD5 4fb686a2851ecb8a272ff97ae3e411dc
BLAKE2b-256 aad8d7bbcef5c03890f5fe983d8419b0c5236af3657c5aa9bddf1991a6ed813a

See more details on using hashes here.

File details

Details for the file multiprocess-0.70.12.2-py36-none-any.whl.

File metadata

  • Download URL: multiprocess-0.70.12.2-py36-none-any.whl
  • Upload date:
  • Size: 107.0 kB
  • Tags: Python 3.6
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.5.0.1 requests/2.21.0 setuptools/56.1.0 requests-toolbelt/0.8.0 tqdm/4.29.1 CPython/3.6.13

File hashes

Hashes for multiprocess-0.70.12.2-py36-none-any.whl
Algorithm Hash digest
SHA256 b3f866f7d9c7acc1a9cb1b6063a29f5cb140ff545b35b71fd4bfdac6f19d75fa
MD5 ca793cf074ea2d71947675e98d3140bf
BLAKE2b-256 dfd0c3011a5bb77f307e68682a5046cce1a2c6591267bf24b5bf3fc4130bb39d

See more details on using hashes here.

File details

Details for the file multiprocess-0.70.12.2-pp37-none-any.whl.

File metadata

  • Download URL: multiprocess-0.70.12.2-pp37-none-any.whl
  • Upload date:
  • Size: 112.2 kB
  • Tags: PyPy
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.5.0.1 requests/2.21.0 setuptools/56.1.0 requests-toolbelt/0.8.0 tqdm/4.29.1 CPython/3.6.13

File hashes

Hashes for multiprocess-0.70.12.2-pp37-none-any.whl
Algorithm Hash digest
SHA256 916a314a1e0f3454033d59672ba6181fa45948ab1091d68cdd479258576e7b27
MD5 3aab8106335af7219c319ff11815f15f
BLAKE2b-256 b7946efd1e87108d5ae86f75ee2049ad5bacbaeb58ee7a521570a144e1d8796d

See more details on using hashes here.

File details

Details for the file multiprocess-0.70.12.2-pp36-none-any.whl.

File metadata

  • Download URL: multiprocess-0.70.12.2-pp36-none-any.whl
  • Upload date:
  • Size: 105.9 kB
  • Tags: PyPy
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.5.0.1 requests/2.21.0 setuptools/56.1.0 requests-toolbelt/0.8.0 tqdm/4.29.1 CPython/3.6.13

File hashes

Hashes for multiprocess-0.70.12.2-pp36-none-any.whl
Algorithm Hash digest
SHA256 0e0a5ae4bd84e4c22baddf824d3b8168214f8c1cce51e2cb080421cb1f7b04d1
MD5 6c614d77cc90c1444497498bd639b3d0
BLAKE2b-256 f14bfe61ba68c54e96802c4b2b181cae4a5b658a96bb9f251485a66344245556

See more details on using hashes here.

File details

Details for the file multiprocess-0.70.12.2-pp27-none-any.whl.

File metadata

  • Download URL: multiprocess-0.70.12.2-pp27-none-any.whl
  • Upload date:
  • Size: 82.0 kB
  • Tags: PyPy
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.5.0.1 requests/2.21.0 setuptools/56.1.0 requests-toolbelt/0.8.0 tqdm/4.29.1 CPython/3.6.13

File hashes

Hashes for multiprocess-0.70.12.2-pp27-none-any.whl
Algorithm Hash digest
SHA256 a9f58945edb234591684c0a181b744a3231643814ef3a8f47cea9a2073b4b2bb
MD5 5a48a09f4d46172a8b020925592f3e17
BLAKE2b-256 970ac9e66e0c3fd4f2a9404c91ba1a967858041c865c958746bb6939454eed10

See more details on using hashes here.

File details

Details for the file multiprocess-0.70.12.2-cp27-cp27m-win_amd64.whl.

File metadata

  • Download URL: multiprocess-0.70.12.2-cp27-cp27m-win_amd64.whl
  • Upload date:
  • Size: 93.3 kB
  • Tags: CPython 2.7m, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.5.0.1 requests/2.21.0 setuptools/56.1.0 requests-toolbelt/0.8.0 tqdm/4.29.1 CPython/3.6.13

File hashes

Hashes for multiprocess-0.70.12.2-cp27-cp27m-win_amd64.whl
Algorithm Hash digest
SHA256 c85ffc38c50c5a4f32f3f3c1a284725b7b5040188f254eba6e572c53d3da525b
MD5 9adee4effdbc6ccaa3e46656980b0886
BLAKE2b-256 ea8be06fb8dccc91ba8060f5f950f1418a656aa3358c4734a841ed6659dc0eff

See more details on using hashes here.

File details

Details for the file multiprocess-0.70.12.2-cp27-cp27m-win32.whl.

File metadata

  • Download URL: multiprocess-0.70.12.2-cp27-cp27m-win32.whl
  • Upload date:
  • Size: 92.3 kB
  • Tags: CPython 2.7m, Windows x86
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.5.0.1 requests/2.21.0 setuptools/56.1.0 requests-toolbelt/0.8.0 tqdm/4.29.1 CPython/3.6.13

File hashes

Hashes for multiprocess-0.70.12.2-cp27-cp27m-win32.whl
Algorithm Hash digest
SHA256 be3ad3eaf204abc646d85e70e41244f66d88200628a0ab867c8fc206b97cedbf
MD5 86259227ebfbeed8a7fcac7f7bcd2060
BLAKE2b-256 a1d8384813353c85d2a6daefc1e334e6211073780a35d9f6bd7d3d46c6d62b47

See more details on using hashes here.

File details

Details for the file multiprocess-0.70.12.2-cp27-cp27m-manylinux1_x86_64.whl.

File metadata

  • Download URL: multiprocess-0.70.12.2-cp27-cp27m-manylinux1_x86_64.whl
  • Upload date:
  • Size: 118.8 kB
  • Tags: CPython 2.7m
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.5.0.1 requests/2.21.0 setuptools/56.1.0 requests-toolbelt/0.8.0 tqdm/4.29.1 CPython/3.6.13

File hashes

Hashes for multiprocess-0.70.12.2-cp27-cp27m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 f12a939cd2f01d0a900e7ef2aaee3c351a49fd2297d7f760b537af22727561b8
MD5 ae1e0e9281e7eedbe8bbae4984802419
BLAKE2b-256 8c1779345dffec97d04019b391258eb0c79cf033796605ba799aad6fd015a5ad

See more details on using hashes here.

File details

Details for the file multiprocess-0.70.12.2-cp27-cp27m-manylinux1_i686.whl.

File metadata

  • Download URL: multiprocess-0.70.12.2-cp27-cp27m-manylinux1_i686.whl
  • Upload date:
  • Size: 116.2 kB
  • Tags: CPython 2.7m
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.5.0.1 requests/2.21.0 setuptools/56.1.0 requests-toolbelt/0.8.0 tqdm/4.29.1 CPython/3.6.13

File hashes

Hashes for multiprocess-0.70.12.2-cp27-cp27m-manylinux1_i686.whl
Algorithm Hash digest
SHA256 9a02237eae21975155c816883479f72e239d16823a6bc063173d59acec9bcf41
MD5 dcc8d90180747f1fcf4ffbbc626e074d
BLAKE2b-256 877af62e81b67e585f4bbc64b63941d2b884970cf3ecea2bd5617c44fcfb2a2b

See more details on using hashes here.

File details

Details for the file multiprocess-0.70.12.2-cp27-cp27m-macosx_10_12_x86_64.whl.

File metadata

  • Download URL: multiprocess-0.70.12.2-cp27-cp27m-macosx_10_12_x86_64.whl
  • Upload date:
  • Size: 90.4 kB
  • Tags: CPython 2.7m, macOS 10.12+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.5.0.1 requests/2.21.0 setuptools/56.1.0 requests-toolbelt/0.8.0 tqdm/4.29.1 CPython/3.6.13

File hashes

Hashes for multiprocess-0.70.12.2-cp27-cp27m-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 35d41e410ca2a32977a483ae1f40f86b193b45cecf85567c2fae402fb8bf172e
MD5 948add2aa22e1c609d260e75db6ab6bf
BLAKE2b-256 3504114627437f9bce88375c7d5abfe52db9c63877f86cfa61e4d90db9d5b4e9

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