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)
participants (1)
-
George Sakkis