ANN: papyros 0.1

G

George Sakkis

I am pleased to announce the first alpha release of Papyros, a
lightweight platform-independent package for parallel processing.
Papyros provides a master-slave model: clients can submit jobs to a
master object which is monitored by one or more slave objects that do
the real work. Two main implementations are provided, one using
multiple threads and one multiple processes in one or more hosts
through Pyro (http://pyro.sourceforge.net/).

Papyros' primary design goal is simplicity: a time consuming loop in a
single-thread single-process program can be replaced with an
equivalent parallel version in a few lines, with minimal boilerplate
code overhead.

To get a copy, visit http://code.google.com/p/papyros/; also available
from the Cheeseshop at http://www.python.org/pypi/papyros/.

George


Sample code
==========
Here's a basic example; for more details go through the README and the
included demo script.

import papyros

class FactorizationJob(papyros.Job):
'''A job for computing the prime factors of an integer.'''
def __call__(self, n):
# <-- find the prime factors here --> #
return factors

# create a multithreded master with three slave threads
from papyros.multithreaded import MultiThreadedMaster
master = MultiThreadedMaster(3)

# factorize concurrently ten random numbers
import random
for _ in xrange(10):
master.addJob(FactorizationJob(random.randrange(1e6,1e7)))

# fetch each job as soon as it finishes
for job in iter(master.popProcessedJob, None):
factors = job.result
print '%d prime factors for %d: %s' % (len(factors), job.args[0],
factors)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,777
Messages
2,569,604
Members
45,229
Latest member
GloryAngul

Latest Threads

Top