Back to index

python3.2  3.2.2
Public Member Functions | Public Attributes | Static Public Attributes | Private Member Functions | Static Private Member Functions | Private Attributes
multiprocessing.pool.ThreadPool Class Reference
Inheritance diagram for multiprocessing.pool.ThreadPool:
Inheritance graph
[legend]
Collaboration diagram for multiprocessing.pool.ThreadPool:
Collaboration graph
[legend]

List of all members.

Public Member Functions

def __init__
def apply
def map
def imap
def imap_unordered
def apply_async
def map_async
def __reduce__
def close
def terminate
def join

Public Attributes

_PyObject_HEAD_EXTRA Py_ssize_t ob_refcnt
struct _typeobjectob_type

Static Public Attributes

 Process = Process

Private Member Functions

def _setup_queues

Static Private Member Functions

def _help_stuff_finish

Private Attributes

 _inqueue
 _outqueue
 _quick_put
 _quick_get

Detailed Description

Definition at line 708 of file pool.py.


Constructor & Destructor Documentation

def multiprocessing.pool.ThreadPool.__init__ (   self,
  processes = None,
  initializer = None,
  initargs = () 
)

Definition at line 712 of file pool.py.

00712 
00713     def __init__(self, processes=None, initializer=None, initargs=()):
00714         Pool.__init__(self, processes, initializer, initargs)

Here is the caller graph for this function:


Member Function Documentation

def multiprocessing.pool.Pool.__reduce__ (   self) [inherited]

Definition at line 437 of file pool.py.

00437 
00438     def __reduce__(self):
00439         raise NotImplementedError(
00440               'pool objects cannot be passed between processes or pickled'
00441               )

def multiprocessing.pool.ThreadPool._help_stuff_finish (   inqueue,
  task_handler,
  size 
) [static, private]

Reimplemented from multiprocessing.pool.Pool.

Definition at line 722 of file pool.py.

00722 
00723     def _help_stuff_finish(inqueue, task_handler, size):
00724         # put sentinels at head of inqueue to make workers finish
00725         inqueue.not_empty.acquire()
00726         try:
00727             inqueue.queue.clear()
00728             inqueue.queue.extend([None] * size)
00729             inqueue.not_empty.notify_all()
00730         finally:
00731             inqueue.not_empty.release()

Reimplemented from multiprocessing.pool.Pool.

Definition at line 715 of file pool.py.

00715 
00716     def _setup_queues(self):
00717         self._inqueue = queue.Queue()
00718         self._outqueue = queue.Queue()
00719         self._quick_put = self._inqueue.put
00720         self._quick_get = self._outqueue.get

def multiprocessing.pool.Pool.apply (   self,
  func,
  args = (),
  kwds = {} 
) [inherited]
Equivalent of `func(*args, **kwds)`.

Definition at line 238 of file pool.py.

00238 
00239     def apply(self, func, args=(), kwds={}):
00240         '''
00241         Equivalent of `func(*args, **kwds)`.
00242         '''
00243         assert self._state == RUN
00244         return self.apply_async(func, args, kwds).get()

Here is the call graph for this function:

Here is the caller graph for this function:

def multiprocessing.pool.Pool.apply_async (   self,
  func,
  args = (),
  kwds = {},
  callback = None,
  error_callback = None 
) [inherited]
Asynchronous version of `apply()` method.

Definition at line 290 of file pool.py.

00290 
00291             error_callback=None):
00292         '''
00293         Asynchronous version of `apply()` method.
00294         '''
00295         assert self._state == RUN
00296         result = ApplyResult(self._cache, callback, error_callback)
00297         self._taskqueue.put(([(result._job, None, func, args, kwds)], None))
00298         return result

Here is the call graph for this function:

Here is the caller graph for this function:

def multiprocessing.pool.Pool.close (   self) [inherited]

Definition at line 442 of file pool.py.

00442 
00443     def close(self):
00444         debug('closing pool')
00445         if self._state == RUN:
00446             self._state = CLOSE
00447             self._worker_handler._state = CLOSE

Here is the caller graph for this function:

def multiprocessing.pool.Pool.imap (   self,
  func,
  iterable,
  chunksize = 1 
) [inherited]
Equivalent of `map()` -- can be MUCH slower than `Pool.map()`.

Definition at line 253 of file pool.py.

00253 
00254     def imap(self, func, iterable, chunksize=1):
00255         '''
00256         Equivalent of `map()` -- can be MUCH slower than `Pool.map()`.
00257         '''
00258         assert self._state == RUN
00259         if chunksize == 1:
00260             result = IMapIterator(self._cache)
00261             self._taskqueue.put((((result._job, i, func, (x,), {})
00262                          for i, x in enumerate(iterable)), result._set_length))
00263             return result
00264         else:
00265             assert chunksize > 1
00266             task_batches = Pool._get_tasks(func, iterable, chunksize)
00267             result = IMapIterator(self._cache)
00268             self._taskqueue.put((((result._job, i, mapstar, (x,), {})
00269                      for i, x in enumerate(task_batches)), result._set_length))
00270             return (item for chunk in result for item in chunk)

Here is the call graph for this function:

def multiprocessing.pool.Pool.imap_unordered (   self,
  func,
  iterable,
  chunksize = 1 
) [inherited]
Like `imap()` method but ordering of results is arbitrary.

Definition at line 271 of file pool.py.

00271 
00272     def imap_unordered(self, func, iterable, chunksize=1):
00273         '''
00274         Like `imap()` method but ordering of results is arbitrary.
00275         '''
00276         assert self._state == RUN
00277         if chunksize == 1:
00278             result = IMapUnorderedIterator(self._cache)
00279             self._taskqueue.put((((result._job, i, func, (x,), {})
00280                          for i, x in enumerate(iterable)), result._set_length))
00281             return result
00282         else:
00283             assert chunksize > 1
00284             task_batches = Pool._get_tasks(func, iterable, chunksize)
00285             result = IMapUnorderedIterator(self._cache)
00286             self._taskqueue.put((((result._job, i, mapstar, (x,), {})
00287                      for i, x in enumerate(task_batches)), result._set_length))
00288             return (item for chunk in result for item in chunk)

Here is the call graph for this function:

def multiprocessing.pool.Pool.join (   self) [inherited]

Definition at line 454 of file pool.py.

00454 
00455     def join(self):
00456         debug('joining pool')
00457         assert self._state in (CLOSE, TERMINATE)
00458         self._worker_handler.join()
00459         self._task_handler.join()
00460         self._result_handler.join()
00461         for p in self._pool:
00462             p.join()

Here is the caller graph for this function:

def multiprocessing.pool.Pool.map (   self,
  func,
  iterable,
  chunksize = None 
) [inherited]
Apply `func` to each element in `iterable`, collecting the results
in a list that is returned.

Definition at line 245 of file pool.py.

00245 
00246     def map(self, func, iterable, chunksize=None):
00247         '''
00248         Apply `func` to each element in `iterable`, collecting the results
00249         in a list that is returned.
00250         '''
00251         assert self._state == RUN
00252         return self.map_async(func, iterable, chunksize).get()

Here is the call graph for this function:

def multiprocessing.pool.Pool.map_async (   self,
  func,
  iterable,
  chunksize = None,
  callback = None,
  error_callback = None 
) [inherited]
Asynchronous version of `map()` method.

Definition at line 300 of file pool.py.

00300 
00301             error_callback=None):
00302         '''
00303         Asynchronous version of `map()` method.
00304         '''
00305         assert self._state == RUN
00306         if not hasattr(iterable, '__len__'):
00307             iterable = list(iterable)
00308 
00309         if chunksize is None:
00310             chunksize, extra = divmod(len(iterable), len(self._pool) * 4)
00311             if extra:
00312                 chunksize += 1
00313         if len(iterable) == 0:
00314             chunksize = 0
00315 
00316         task_batches = Pool._get_tasks(func, iterable, chunksize)
00317         result = MapResult(self._cache, chunksize, len(iterable), callback,
00318                            error_callback=error_callback)
00319         self._taskqueue.put((((result._job, i, mapstar, (x,), {})
00320                               for i, x in enumerate(task_batches)), None))
00321         return result

Here is the call graph for this function:

Here is the caller graph for this function:

def multiprocessing.pool.Pool.terminate (   self) [inherited]

Definition at line 448 of file pool.py.

00448 
00449     def terminate(self):
00450         debug('terminating pool')
00451         self._state = TERMINATE
00452         self._worker_handler._state = TERMINATE
00453         self._terminate()

Here is the caller graph for this function:


Member Data Documentation

Reimplemented from multiprocessing.pool.Pool.

Definition at line 716 of file pool.py.

Reimplemented from multiprocessing.pool.Pool.

Definition at line 717 of file pool.py.

Reimplemented from multiprocessing.pool.Pool.

Definition at line 719 of file pool.py.

Reimplemented from multiprocessing.pool.Pool.

Definition at line 718 of file pool.py.

Definition at line 107 of file object.h.

struct _typeobject* _object::ob_type [inherited]

Definition at line 108 of file object.h.

Definition at line 134 of file pool.py.


The documentation for this class was generated from the following file: