Back to index

python3.2  3.2.2
Classes | Functions | Variables
multiprocessing.pool Namespace Reference

Classes

class  MaybeEncodingError
class  Pool
class  ApplyResult
class  MapResult
class  IMapIterator
class  IMapUnorderedIterator
class  ThreadPool

Functions

def mapstar
def worker

Variables

list __all__ = ['Pool']
int RUN = 0
int CLOSE = 1
int TERMINATE = 2
tuple job_counter = itertools.count()

Function Documentation

Definition at line 64 of file pool.py.

00064 
00065 def mapstar(args):
00066     return list(map(*args))
00067 
00068 #
00069 # Code run by worker processes
00070 #

def multiprocessing.pool.worker (   inqueue,
  outqueue,
  initializer = None,
  initargs = (),
  maxtasks = None 
)

Definition at line 88 of file pool.py.

00088 
00089 def worker(inqueue, outqueue, initializer=None, initargs=(), maxtasks=None):
00090     assert maxtasks is None or (type(maxtasks) == int and maxtasks > 0)
00091     put = outqueue.put
00092     get = inqueue.get
00093     if hasattr(inqueue, '_writer'):
00094         inqueue._writer.close()
00095         outqueue._reader.close()
00096 
00097     if initializer is not None:
00098         initializer(*initargs)
00099 
00100     completed = 0
00101     while maxtasks is None or (maxtasks and completed < maxtasks):
00102         try:
00103             task = get()
00104         except (EOFError, IOError):
00105             debug('worker got EOFError or IOError -- exiting')
00106             break
00107 
00108         if task is None:
00109             debug('worker got sentinel -- exiting')
00110             break
00111 
00112         job, i, func, args, kwds = task
00113         try:
00114             result = (True, func(*args, **kwds))
00115         except Exception as e:
00116             result = (False, e)
00117         try:
00118             put((job, i, result))
00119         except Exception as e:
00120             wrapped = MaybeEncodingError(e, result[1])
00121             debug("Possible encoding error while sending result: %s" % (
00122                 wrapped))
00123             put((job, i, (False, wrapped)))
00124         completed += 1
00125     debug('worker exiting after %d tasks' % completed)
00126 
00127 #
00128 # Class representing a process pool
00129 #

Here is the call graph for this function:


Variable Documentation

Definition at line 35 of file pool.py.

Definition at line 55 of file pool.py.

Definition at line 62 of file pool.py.

Definition at line 54 of file pool.py.

Definition at line 56 of file pool.py.