7 __author__ =
'Wim Lavrijsen (WLavrijsen@lbl.gov)'
9 import AthenaPython.PyAthena
as PyAthena
11 GlobalSettings = {
'label' :
'hephaestus',
'event-based' :
True }
14 def __init__( self, name = "HephaestusAuditor", mode = 'leak-check', **kw ):
16 super( HephaestusAuditor, self ).
__init__( **kw )
40 if mode ==
'leak-check':
44 if startup
or 'full' in self.
auditOn:
48 elif mode ==
'delete-check':
50 self.
_start = DeleteChecker.start
51 self.
_stop = DeleteChecker.stop
54 raise RuntimeError(
'unknown mode: %s (expected leak-check or delete-check)' % mode )
61 if 'full-athena' in self.
auditOn:
65 if not GlobalSettings[
'event-based' ]:
66 self.
_memtrack._profname( GlobalSettings[
'label' ] )
68 return PyAthena.StatusCode.Success
71 if 'full-athena' in self.
auditOn:
74 return PyAthena.StatusCode.Success
76 def before( self, evt_name, comp_name ):
79 if GlobalSettings[
'event-based' ]
and evt_name.lower() ==
'execute'\
82 self.
_memtrack._profname( GlobalSettings[
'label' ] +
'_execute.%d' % self.
_evt )
86 def after( self, evt_name, comp_name, sc ):
111 dct[
'GlobalSettings' ] = GlobalSettings
117 dct[
'pid' ] = os.getpid()
126 global GlobalSettings
127 for k,v
in dct[
'GlobalSettings' ].
items():
128 GlobalSettings[ k ] = v
134 if dct[
'pid' ] == os.getpid():
135 self.
_evt = dct[
'_evt' ]