Module pprocess
[hide private]
[frames] | no frames]

Module pprocess

source code


A simple parallel processing API for Python, inspired somewhat by the thread
module, slightly less by pypar, and slightly less still by pypvm.

Copyright (C) 2005, 2006, 2007 Paul Boddie <paul@boddie.org.uk>

This program is free software; you can redistribute it and/or modify it under
the terms of the GNU Lesser General Public License as published by the Free
Software Foundation; either version 3 of the License, or (at your option) any
later version.

This program is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
details.

You should have received a copy of the GNU Lesser General Public License along
with this program.  If not, see <http://www.gnu.org/licenses/>.




Version: 0.3.1

Classes [hide private]
  AcknowledgementError
  Channel
A communications channel.
  Exchange
A communications exchange that can be used to detect channels which are ready to communicate.
  ManagedCallable
A callable managed by an exchange.
  Map
An exchange which can be used like the built-in 'map' function.
  Queue
An exchange acting as a queue, making data from created processes available in the order in which it is received.
  MakeParallel
A wrapper around functions making them able to communicate results.
  MakeReusable
A wrapper around functions making them able to communicate results in a reusable fashion.
Functions [hide private]
 
create()
Create a new process, returning a communications channel to both the creating process and the created process.
source code
 
exit(channel)
Terminate a created process, closing the given 'channel'.
source code
 
start(callable, *args, **kw)
Create a new process which shall start running in the given 'callable'.
source code
 
waitall()
Wait for all created processes to terminate.
source code
 
pmap(callable, sequence, limit=None)
A parallel version of the built-in map function with an optional process 'limit'.
source code
Function Details [hide private]

start(callable, *args, **kw)

source code 

Create a new process which shall start running in the given 'callable'.
Additional arguments to the 'callable' can be given as additional arguments
to this function.

Return a communications channel to the creating process. For the created
process, supply a channel as the 'channel' parameter in the given 'callable'
so that it may send data back to the creating process.

pmap(callable, sequence, limit=None)

source code 

A parallel version of the built-in map function with an optional process
'limit'. The given 'callable' should not be parallel-aware (that is, have a
'channel' parameter) since it will be wrapped for parallel communications
before being invoked.

Return the processed 'sequence' where each element in the sequence is
processed by a different process.