| # Gaudi Framework, version v25r0 |

Home |  | Generated: Mon Feb 17 2014

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- Class List
- Class Index
- Class Hierarchy
- Class Members

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Public Member Functions | Public Attributes | Private Member Functions | Static Private Attributes | List of all members
GaudiMP.Parallel.Task Class Reference
Inheritance diagram for GaudiMP.Parallel.Task:
[legend]
Collaboration diagram for GaudiMP.Parallel.Task:
[legend]

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

## Member Function Documentation

def GaudiMP.Parallel.Task.__new__ | ( |  | cls,
|  |  | args,
|  |  | kwargs
| ) |  |

Definition at line 52 of file Parallel.py.

52
53 def __new__ ( cls, *args, **kwargs ):
54 task = object.__new__( cls )
55 task.output = ()
56 task.environ = {}
57 for k,v in os.environ.items(): task.environ[k] = v
58 task.cwd = os.getcwd()
return task

def GaudiMP.Parallel.Task._mergeResults | ( |  | self,
|  |  | result
| ) |  |
| private

Definition at line 67 of file Parallel.py.

67
68 def _mergeResults(self, result) :
69 if type(result) is not type(self.output) :
70 raise TypeError("output type is not same as obtained result")
71 #--No iteratable---
72 if not hasattr( result , '__iter__' ):
73 if hasattr(self.output,'Add') : self.output.Add(result)
74 elif hasattr(self.output,'__iadd__') : self.output += result
75 elif hasattr(self.output,'__add__') : self.output = self.output + result
76 else : raise TypeError('result cannot be added')
77 #--Dictionary---
78 elif type(result) is dict :
79 if self.output.keys() <= result.keys(): minkeys = self.output.keys()
80 else: minkeys = result.keys()
81 for key in result.keys() :
82 if key in self.output :
83 if hasattr(self.output[key],'Add') : self.output[key].Add(result[key])
84 elif hasattr(self.output[key],'__iadd__') : self.output[key] += result[key]
85 elif hasattr(self.output[key],'__add__') : self.output[key] = self.output[key] + result[key]
86 else : raise TypeError('result cannot be added')
87 else :
88 self.output[key] = result[key]
89 #--Anything else (list)
90 else :
91 for i in range( min( len(self.output) , len(result)) ):
92 if hasattr(self.output[i],'Add') : self.output[i].Add(result[i])
93 elif hasattr(self.output[i],'__iadd__') : self.output[i] += result[i]
94 elif hasattr(self.output[i],'__add__') : self.output[i] = self.output[i] + result[i]
else : raise TypeError('result cannot be added')

def GaudiMP.Parallel.Task._resetOutput | ( |  | self | ) |
| private

Definition at line 95 of file Parallel.py.

95
96 def _resetOutput(self):
97 output = (type(self.output) is dict) and self.output.values() or self.output
98 for o in output :
99 if hasattr(o, 'Reset'): o.Reset()
100

def GaudiMP.Parallel.Task.finalize | ( |  | self | ) |

Definition at line 65 of file Parallel.py.

65
66 def finalize(self) :
pass

def GaudiMP.Parallel.Task.initializeLocal | ( |  | self | ) |

Definition at line 59 of file Parallel.py.

59
60 def initializeLocal(self):
pass

def GaudiMP.Parallel.Task.initializeRemote | ( |  | self | ) |

Definition at line 61 of file Parallel.py.

61
62 def initializeRemote(self):
pass

def GaudiMP.Parallel.Task.process | ( |  | self,
|  |  | item
| ) |  |

Definition at line 63 of file Parallel.py.

63
64 def process(self, item):
pass

## Member Data Documentation

GaudiMP.Parallel.Task._initializeDone False
| static private

Definition at line 51 of file Parallel.py.

GaudiMP.Parallel.Task.output

Definition at line 74 of file Parallel.py.

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

- /afs/cern.ch/sw/Gaudi/releases/GAUDI/GAUDI_v25r0/GaudiMP/python/GaudiMP/Parallel.py