| # Gaudi Framework, version v21r7p1 |

Home |  | Generated: 15 Feb 2010

# 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 74 of file Parallel.py.

## Member Function Documentation

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

Definition at line 79 of file Parallel.py.

    00079                                         :
    00080         task = object.__new__( cls, *args, **kwargs )
    00081         task.output = ()
    00082         task.environ = {}
    00083         for k,v in os.environ.items(): task.environ[k] = v
    00084         task.cwd = os.getcwd()
    00085         return task
        def initializeLocal(self):

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

Definition at line 86 of file Parallel.py.

    00086                              :
    00087         pass
        def initializeRemote(self):

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

Definition at line 88 of file Parallel.py.

    00088                               :
    00089         pass
        def process(self, item):

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

Definition at line 90 of file Parallel.py.

    00090                            :
    00091         pass
        def finalize(self) :

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

Definition at line 92 of file Parallel.py.

    00092                        :
    00093         pass
        def _mergeResults(self, result) :

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

Definition at line 94 of file Parallel.py.

    00094                                     :
    00095         if type(result) is not type(self.output) :
    00096             raise TypeError("output type is not same as obtained result")
    00097         #--No iteratable---
    00098         if not hasattr( result , '__iter__' ):
    00099             if hasattr(self.output,'Add') : self.output.Add(result)
    00100             elif hasattr(self.output,'__iadd__') : self.output += result
    00101             elif hasattr(self.output,'__add__') : self.output = self.output + result
    00102             else : raise TypeError('result cannot be added')
    00103         #--Dictionary---
    00104         elif type(result) is dict :
    00105             if self.output.keys() <= result.keys(): minkeys = self.output.keys()
    00106             else: minkeys = result.keys()
    00107             for key in result.keys() :
    00108                 if key in self.output :
    00109                     if hasattr(self.output[key],'Add') : self.output[key].Add(result[key])
    00110                     elif hasattr(self.output[key],'__iadd__') : self.output[key] += result[key]
    00111                     elif hasattr(self.output[key],'__add__') : self.output[key] = self.output[key] + result[key]
    00112                     else : raise TypeError('result cannot be added')
    00113                 else :
    00114                     self.output[key] = result[key]
    00115         #--Anything else (list)
    00116         else :
    00117             for i in range( min( len(self.output) , len(result)) ):
    00118                 if hasattr(self.output[i],'Add') : self.output[i].Add(result[i])
    00119                 elif hasattr(self.output[i],'__iadd__') : self.output[i] += result[i]
    00120                 elif hasattr(self.output[i],'__add__') : self.output[i] = self.output[i] + result[i]
    00121                 else : raise TypeError('result cannot be added')
        def _resetOutput(self):

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

Definition at line 122 of file Parallel.py.

    00122                           :
    00123         output =  (type(self.output) is dict) and self.output.values() or self.output
    00124         for o in output :
    00125             if hasattr(o, 'Reset'): o.Reset()
    00126
    00127
    class WorkManager(object) :

## Member Data Documentation

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

Definition at line 78 of file Parallel.py.

GaudiPython::Parallel::Task::output

Definition at line 101 of file Parallel.py.

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

- /afs/cern.ch/sw/Gaudi/releases/GAUDI/GAUDI_v21r7p1/GaudiPython/python/GaudiPython/Parallel.py