Skip to main content

Package for using processes mimicking 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.map_async(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.39.zip (163.2 kB view details)

Uploaded Source

Built Distributions

processing-0.39.win32-py2.5.exe (183.4 kB view details)

Uploaded Source

processing-0.39.win32-py2.4.exe (181.8 kB view details)

Uploaded Source

File details

Details for the file processing-0.39.zip.

File metadata

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

File hashes

Hashes for processing-0.39.zip
Algorithm Hash digest
SHA256 0c4cdfa49caaeb852198a7bc03b95386710810962d1463d925acbd85c3021b71
MD5 d6f1e4a7c148356a0bde504cf434dde7
BLAKE2b-256 bf042716b35eec738da2f8815b6b15ca17909962d73ba1527a3d7c30569f0b0e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for processing-0.39.win32-py2.5.exe
Algorithm Hash digest
SHA256 f2731425fee97d6eb284d61c8efff182b7a4647412389a864e2c23479d48af3b
MD5 bc09be076d54ba5e81b5f21eede3b17d
BLAKE2b-256 b490f37404769f328c44172086b1c7acd7da6b1cfea5e072012f2775c22f8fba

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for processing-0.39.win32-py2.4.exe
Algorithm Hash digest
SHA256 01451b99cba0295e75bd2faaa1da1e5b7fa55ec9398362dd0a25067c82a77447
MD5 3c4816ebb031e42df39db69202b7039c
BLAKE2b-256 60f5a91440382ae013f42e4c78d95220cdd6648277aff641de40fd822ef68808

See more details on using hashes here.

Supported by

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