| Classes | Job Modules | Data Objects | Services | Algorithms | Tools | Packages | Directories | Tracs |

In This Package:

GaudiPython::Parallel::Task Class Reference

List of all members.

Public Member Functions

def __new__
def initializeLocal
def initializeRemote
def process
def finalize

Public Attributes

 output

Private Member Functions

def _mergeResults
def _resetOutput

Static Private Attributes

 _initializeDone = False

Detailed Description

Basic base class to encapsulate any processing that is going to be porcessed in parallel.
    User class much inherit from it and implement the methods initializeLocal,
    initializeRemote, process and finalize.   

Definition at line 66 of file Parallel.py.


Member Function Documentation

def GaudiPython::Parallel::Task::__new__ (   cls,
  args,
  kwargs 
)

Definition at line 69 of file Parallel.py.

00071                                       :
00072     task = object.__new__( cls, *args, **kwargs )
00073     task.output = ()
00074     task.environ = {}
00075     for k,v in os.environ.items(): task.environ[k] = v
    task.cwd = os.getcwd()

def GaudiPython::Parallel::Task::initializeLocal (   self  ) 

Definition at line 76 of file Parallel.py.

00078                            :
    pass

def GaudiPython::Parallel::Task::initializeRemote (   self  ) 

Definition at line 78 of file Parallel.py.

00078                            :
00079     pass
  def initializeRemote(self):

def GaudiPython::Parallel::Task::process (   self,
  item 
)

Definition at line 80 of file Parallel.py.

00080                             :
00081     pass
  def process(self, item):

def GaudiPython::Parallel::Task::finalize (   self  ) 

Definition at line 82 of file Parallel.py.

00082                          :
00083     pass
  def finalize(self) :

def GaudiPython::Parallel::Task::_mergeResults (   self,
  result 
) [private]

Definition at line 84 of file Parallel.py.

00084                      :
00085     pass
00086   def _mergeResults(self, result) :
00087    if type(result) is not type(self.output) :
00088      raise TypeError("output type is not same as obtained result")
00089    #--No iteratable---
00090    if not hasattr( result , '__iter__' ):
00091      if hasattr(self.output,'Add') : self.output.Add(result)
00092      elif hasattr(self.output,'__iadd__') : self.output += result
00093      elif hasattr(self.output,'__add__') : self.output = self.output + result
00094      else : raise TypeError('result cannot be added')
00095    #--Dictionary---
00096    elif type(result) is dict :
00097      if self.output.keys() <= result.keys(): minkeys = self.output.keys()
00098      else: minkeys = result.keys()
00099      for key in result.keys() :
00100        if key in self.output :
00101          if hasattr(self.output[key],'Add') : self.output[key].Add(result[key])
00102          elif hasattr(self.output[key],'__iadd__') : self.output[key] += result[key]
00103          elif hasattr(self.output[key],'__add__') : self.output[key] = self.output[key] + result[key]
00104          else : raise TypeError('result cannot be added')
00105        else :
00106          self.output[key] = result[key]
00107    #--Anything else (list)
00108    else :
00109      for i in range( min( len(self.output) , len(result)) ):
00110        if hasattr(self.output[i],'Add') : self.output[i].Add(result[i])
00111        elif hasattr(self.output[i],'__iadd__') : self.output[i] += result[i]
       elif hasattr(self.output[i],'__add__') : self.output[i] = self.output[i] + result[i]

def GaudiPython::Parallel::Task::_resetOutput (   self  )  [private]

Definition at line 112 of file Parallel.py.

00112                                               : self.output[i] = self.output[i] + result[i]
00113        else : raise TypeError('result cannot be added')
00114   def _resetOutput(self):
00115     output =  (type(self.output) is dict) and self.output.values() or self.output
00116     for o in output :
00117       if hasattr(o, 'Reset'): o.Reset()


Member Data Documentation

GaudiPython::Parallel::Task::_initializeDone = False [static, private]

Definition at line 68 of file Parallel.py.

GaudiPython::Parallel::Task::output

Definition at line 91 of file Parallel.py.


The documentation for this class was generated from the following file:
| Classes | Job Modules | Data Objects | Services | Algorithms | Tools | Packages | Directories | Tracs |

Generated on Mon Apr 11 19:58:58 2011 for GaudiPython by doxygen 1.4.7