Back to index

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

List of all members.

Public Member Functions

def __init__
def __iter__
def next

Public Attributes

_PyObject_HEAD_EXTRA Py_ssize_t ob_refcnt
struct _typeobjectob_type

Private Member Functions

def _set
def _set_length

Private Attributes

 _cond
 _job
 _cache
 _items
 _index
 _length
 _unsorted

Static Private Attributes

 __next__ = next

Detailed Description

Definition at line 618 of file pool.py.


Constructor & Destructor Documentation

def multiprocessing.pool.IMapIterator.__init__ (   self,
  cache 
)

Definition at line 620 of file pool.py.

00620 
00621     def __init__(self, cache):
00622         self._cond = threading.Condition(threading.Lock())
00623         self._job = next(job_counter)
00624         self._cache = cache
00625         self._items = collections.deque()
00626         self._index = 0
00627         self._length = None
00628         self._unsorted = {}
00629         cache[self._job] = self

Here is the caller graph for this function:


Member Function Documentation

Definition at line 630 of file pool.py.

00630 
00631     def __iter__(self):
00632         return self

def multiprocessing.pool.IMapIterator._set (   self,
  i,
  obj 
) [private]

Reimplemented in multiprocessing.pool.IMapUnorderedIterator.

Definition at line 658 of file pool.py.

00658 
00659     def _set(self, i, obj):
00660         self._cond.acquire()
00661         try:
00662             if self._index == i:
00663                 self._items.append(obj)
00664                 self._index += 1
00665                 while self._index in self._unsorted:
00666                     obj = self._unsorted.pop(self._index)
00667                     self._items.append(obj)
00668                     self._index += 1
00669                 self._cond.notify()
00670             else:
00671                 self._unsorted[i] = obj
00672 
00673             if self._index == self._length:
00674                 del self._cache[self._job]
00675         finally:
00676             self._cond.release()

Here is the caller graph for this function:

def multiprocessing.pool.IMapIterator._set_length (   self,
  length 
) [private]

Definition at line 677 of file pool.py.

00677 
00678     def _set_length(self, length):
00679         self._cond.acquire()
00680         try:
00681             self._length = length
00682             if self._index == self._length:
00683                 self._cond.notify()
00684                 del self._cache[self._job]
00685         finally:
00686             self._cond.release()
00687 
00688 #
00689 # Class whose instances are returned by `Pool.imap_unordered()`
00690 #

def multiprocessing.pool.IMapIterator.next (   self,
  timeout = None 
)

Definition at line 633 of file pool.py.

00633 
00634     def next(self, timeout=None):
00635         self._cond.acquire()
00636         try:
00637             try:
00638                 item = self._items.popleft()
00639             except IndexError:
00640                 if self._index == self._length:
00641                     raise StopIteration
00642                 self._cond.wait(timeout)
00643                 try:
00644                     item = self._items.popleft()
00645                 except IndexError:
00646                     if self._index == self._length:
00647                         raise StopIteration
00648                     raise TimeoutError
00649         finally:
00650             self._cond.release()
00651 
00652         success, value = item
00653         if success:
00654             return value
00655         raise value

Here is the caller graph for this function:


Member Data Documentation

Definition at line 656 of file pool.py.

Definition at line 623 of file pool.py.

Definition at line 621 of file pool.py.

Reimplemented in multiprocessing.pool.IMapUnorderedIterator.

Definition at line 625 of file pool.py.

Definition at line 624 of file pool.py.

Definition at line 622 of file pool.py.

Definition at line 626 of file pool.py.

Definition at line 627 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.


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