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 (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.tgz
$ cd multiprocess-0.70.12
$ 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.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-py39-none-any.whl (128.7 kB view details)

Uploaded Python 3.9

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

Uploaded Python 3.8

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

Uploaded Python 3.7

multiprocess-0.70.12-py36-none-any.whl (106.9 kB view details)

Uploaded Python 3.6

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

Uploaded PyPy

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

Uploaded PyPy

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

Uploaded PyPy

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

Uploaded CPython 2.7mWindows x86-64

multiprocess-0.70.12-cp27-cp27m-win32.whl (92.2 kB view details)

Uploaded CPython 2.7mWindows x86

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

Uploaded CPython 2.7m

multiprocess-0.70.12-cp27-cp27m-manylinux1_i686.whl (116.1 kB view details)

Uploaded CPython 2.7m

multiprocess-0.70.12-cp27-cp27m-macosx_10_12_x86_64.whl (90.3 kB view details)

Uploaded CPython 2.7mmacOS 10.12+ x86-64

File details

Details for the file multiprocess-0.70.12.zip.

File metadata

  • Download URL: multiprocess-0.70.12.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.18.1 setuptools/36.0.1 requests-toolbelt/0.8.0 tqdm/4.23.4 CPython/3.6.13

File hashes

Hashes for multiprocess-0.70.12.zip
Algorithm Hash digest
SHA256 853d02581a03b3bf7872f5e997d2e2b62e177c22a9d05158dc96a675854f2b60
MD5 602de2631ada31a078a0585d0df657a4
BLAKE2b-256 c6ffd85f76f7fb62745664924414cb58340725b61a61f9226db10bec16de01c9

See more details on using hashes here.

File details

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

File metadata

  • Download URL: multiprocess-0.70.12-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.18.1 setuptools/36.0.1 requests-toolbelt/0.8.0 tqdm/4.23.4 CPython/3.6.13

File hashes

Hashes for multiprocess-0.70.12-py39-none-any.whl
Algorithm Hash digest
SHA256 c0fa97754295874627876b5195a04c338b2aff58dcb788decdc71c1a710144d0
MD5 33a8ae906cca92bb3f1821832b399bc0
BLAKE2b-256 78eeef4f551b823cecc5354748ac4d797347b831a338b268d17ab8a1bea0adef

See more details on using hashes here.

File details

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

File metadata

  • Download URL: multiprocess-0.70.12-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.18.1 setuptools/36.0.1 requests-toolbelt/0.8.0 tqdm/4.23.4 CPython/3.6.13

File hashes

Hashes for multiprocess-0.70.12-py38-none-any.whl
Algorithm Hash digest
SHA256 2b7d63c9efd959d288c4651261e04499d6431347797bce9dfae50a2781aa6aeb
MD5 2796f004d19889939675bdc4bb7b6ab3
BLAKE2b-256 667c85a5f8463afeb7f80ba749d07561a963233ddf7f63bddffbdb520865307f

See more details on using hashes here.

File details

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

File metadata

  • Download URL: multiprocess-0.70.12-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.18.1 setuptools/36.0.1 requests-toolbelt/0.8.0 tqdm/4.23.4 CPython/3.6.13

File hashes

Hashes for multiprocess-0.70.12-py37-none-any.whl
Algorithm Hash digest
SHA256 48f464a28546830584255f34e35efa6bd7abafe1bcbe82f5c2ed7b9a52cb817b
MD5 c2591a2474bb763a5c761995d8a8e319
BLAKE2b-256 35bea428bdf9a76cb7c60e516f7849dc8457a942ea7ae6ce3dfa0afad1e566be

See more details on using hashes here.

File details

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

File metadata

  • Download URL: multiprocess-0.70.12-py36-none-any.whl
  • Upload date:
  • Size: 106.9 kB
  • Tags: Python 3.6
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.5.0.1 requests/2.18.1 setuptools/36.0.1 requests-toolbelt/0.8.0 tqdm/4.23.4 CPython/3.6.13

File hashes

Hashes for multiprocess-0.70.12-py36-none-any.whl
Algorithm Hash digest
SHA256 56220afc52254e25d2698149e267247f4b39bc43e036306db138db080bfb2476
MD5 e8a52e46801bc6fa6627e4cdb375ca16
BLAKE2b-256 ddbf995e61e96aa7fcf67bd981d51d7ee73be64ddd34fb5dccb0a032f7f5b898

See more details on using hashes here.

File details

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

File metadata

  • Download URL: multiprocess-0.70.12-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.18.1 setuptools/36.0.1 requests-toolbelt/0.8.0 tqdm/4.23.4 CPython/3.6.13

File hashes

Hashes for multiprocess-0.70.12-pp37-none-any.whl
Algorithm Hash digest
SHA256 3ca559b8da9cf4060610c32d02e8c3100574005e51fa3bc4884a099ec6b33f79
MD5 35e5b555423135a0d9c787e06d92e05e
BLAKE2b-256 d56b3298b6392682855b4f00d5e755d83fafce90188865961fd1ead58f1b0d7f

See more details on using hashes here.

File details

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

File metadata

  • Download URL: multiprocess-0.70.12-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.18.1 setuptools/36.0.1 requests-toolbelt/0.8.0 tqdm/4.23.4 CPython/3.6.13

File hashes

Hashes for multiprocess-0.70.12-pp36-none-any.whl
Algorithm Hash digest
SHA256 4b1f2e78da216c8099b0a5edeac03c28bde6e21556699f62d4322ac1041238b8
MD5 97ebefd20faacf277c62d49872c6c036
BLAKE2b-256 60c9748480c4cc2c08cd7425c8a70449432790b0b83136e539e140bac0c93275

See more details on using hashes here.

File details

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

File metadata

  • Download URL: multiprocess-0.70.12-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.18.1 setuptools/36.0.1 requests-toolbelt/0.8.0 tqdm/4.23.4 CPython/3.6.13

File hashes

Hashes for multiprocess-0.70.12-pp27-none-any.whl
Algorithm Hash digest
SHA256 a630d8441f108ad6aa973bc3f308161a4920b97fb562aea6eddf5793ce588a48
MD5 d32871da7fc24c6253d74b13b06ae4c9
BLAKE2b-256 a9894459e52f7829908910f9e1d80db65b8c7103cf3e1a09e0973ad324392103

See more details on using hashes here.

File details

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

File metadata

  • Download URL: multiprocess-0.70.12-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.18.1 setuptools/36.0.1 requests-toolbelt/0.8.0 tqdm/4.23.4 CPython/3.6.13

File hashes

Hashes for multiprocess-0.70.12-cp27-cp27m-win_amd64.whl
Algorithm Hash digest
SHA256 b5f061bd10154d5069e4f95276a1f9fab397015128c9ae2f7635ccc454e9185c
MD5 eadc9d65efa0b7b45b80338b6a303cf8
BLAKE2b-256 7774358fe2deb05fb63e1316107ee21fdd030ed5db95522a18fcdc5bbbe97d25

See more details on using hashes here.

File details

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

File metadata

  • Download URL: multiprocess-0.70.12-cp27-cp27m-win32.whl
  • Upload date:
  • Size: 92.2 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.18.1 setuptools/36.0.1 requests-toolbelt/0.8.0 tqdm/4.23.4 CPython/3.6.13

File hashes

Hashes for multiprocess-0.70.12-cp27-cp27m-win32.whl
Algorithm Hash digest
SHA256 ff0491b2bf8a090c007575cd953d6609301b280e45c430abce2be3c92e74ebfc
MD5 c778cb6801693ed19eb96aaad0fb2832
BLAKE2b-256 0d9bc900fc1725e22413a0fb241d8af9e87b76f38492d94ea2273564a7c99e4d

See more details on using hashes here.

File details

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

File metadata

  • Download URL: multiprocess-0.70.12-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.18.1 setuptools/36.0.1 requests-toolbelt/0.8.0 tqdm/4.23.4 CPython/3.6.13

File hashes

Hashes for multiprocess-0.70.12-cp27-cp27m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 fd60cc4853382937d1811945bb9cf5d2da1d030adf6fb3b84e9b84af0a49dad6
MD5 3c2cf31bd4562891a2c15f9158b5090c
BLAKE2b-256 12c3087ba3890842124eeeb004a8dbd30d7dba3be5ed8b46ba1855ad65e6ee33

See more details on using hashes here.

File details

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

File metadata

  • Download URL: multiprocess-0.70.12-cp27-cp27m-manylinux1_i686.whl
  • Upload date:
  • Size: 116.1 kB
  • Tags: CPython 2.7m
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.5.0.1 requests/2.18.1 setuptools/36.0.1 requests-toolbelt/0.8.0 tqdm/4.23.4 CPython/3.6.13

File hashes

Hashes for multiprocess-0.70.12-cp27-cp27m-manylinux1_i686.whl
Algorithm Hash digest
SHA256 4f55a1468c916dd0aa37314c3126ee5a5ecf221340c097d2862ffcfa8c1c33e1
MD5 dc4308018cdd21271d45f7caaba26fa9
BLAKE2b-256 b16ebd188c8adbb030a43c3f01afa2969a99ca8bec0467d3e101e3f781cb97a8

See more details on using hashes here.

File details

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

File metadata

  • Download URL: multiprocess-0.70.12-cp27-cp27m-macosx_10_12_x86_64.whl
  • Upload date:
  • Size: 90.3 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.18.1 setuptools/36.0.1 requests-toolbelt/0.8.0 tqdm/4.23.4 CPython/3.6.13

File hashes

Hashes for multiprocess-0.70.12-cp27-cp27m-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 19f74377786aa6be34bdee8890f7800fe141079f22257318aa30aabe8b208a98
MD5 ecaad73b73fbaf6eb36bb7ea74a854d9
BLAKE2b-256 e180be4383be35c650403dff06d59168259c1a45ef111926e291395e9d3d79ea

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