Skip to main content

Package for using processes which mimics the threading module

Project description

processing is a package for the Python language which supports the spawning of processes using the API of the standard library’s threading module. It runs on both Unix and Windows.

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.

Examples

The processing.Process class follows the API of threading.Thread. For example

from processing 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 processing 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 processing 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 processing import Pool
>>> def f(x): return x*x
...
>>> p = Pool(4)
>>> result = p.mapAsync(f, range(10))
>>> print result.get(timeout=1)
[0, 1, 4, 9, 16, 25, 36, 49, 64, 81]

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

processing-0.52.zip (178.0 kB view details)

Uploaded Source

Built Distributions

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

processing-0.52.win32-py2.5.exe (191.2 kB view details)

Uploaded Source

processing-0.52.win32-py2.4.exe (189.7 kB view details)

Uploaded Source

File details

Details for the file processing-0.52.zip.

File metadata

  • Download URL: processing-0.52.zip
  • Upload date:
  • Size: 178.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for processing-0.52.zip
Algorithm Hash digest
SHA256 976fa4f8d30e8dc8216ae24d44c95587ae05ab39e9ac4bdc10691cab51fca11d
MD5 62772fa3002d003b2395ed669072d51d
BLAKE2b-256 3b2da6f17cc99d9c45c33eb3eccd6999505d9197b31f0845a845919032262a01

See more details on using hashes here.

File details

Details for the file processing-0.52.win32-py2.5.exe.

File metadata

File hashes

Hashes for processing-0.52.win32-py2.5.exe
Algorithm Hash digest
SHA256 027d91c0ddd2343d2b5d44aee0dbe42a1edb6d9a490870a8f86a741517a697d6
MD5 d1a938a89cf9fa7d2641b99c0a2a185a
BLAKE2b-256 f972746f2679800541e66e8950838c18a0eeb0d835a28447f6a116c8c66659b5

See more details on using hashes here.

File details

Details for the file processing-0.52.win32-py2.4.exe.

File metadata

File hashes

Hashes for processing-0.52.win32-py2.4.exe
Algorithm Hash digest
SHA256 4818d99c24472421fc026ef66dbd8f9b3b991200ba77950f350a9910b6b1c840
MD5 e8be142011636b440011ef577378ceda
BLAKE2b-256 a7ebd505d4680fd925e363128ba7b8ea348a0b9a6f250477144ff1c38e3045b6

See more details on using hashes here.

Supported by