| The Gaudi Framework v27r1

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

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

Public Member Functions | Public Attributes | List of all members
GaudiMP.pTools.Syncer Class Reference
Inheritance diagram for GaudiMP.pTools.Syncer:
[legend]
Collaboration diagram for GaudiMP.pTools.Syncer:
[legend]

## Public Member Functions
def | __init__
def | syncAll
def | syncAllRolling (self)
def | processHang (self)
def | checkAll (self)
def | checkLastEvents (self)

## Public Attributes
| limit
| step
| d
| manyEvents
| limitFirst
| keys
| nWorkers
| log

## Detailed Description

Definition at line 567 of file pTools.py.

## Constructor & Destructor Documentation

def GaudiMP.pTools.Syncer.__init__ | ( |  | self,
|  |  | nWorkers,
|  |  | log,
|  |  | manyEvents = `False`,
|  |  | limit = `None`,
|  |  | step = `None`,
|  |  | firstEvent = `None`
| ) |  |

Definition at line 569 of file pTools.py.

569 limit=None, step=None, firstEvent=None ) :
570 # Class to help synchronise the sub-processes
571 self.limit = limit
572 self.step = step
573 self.d = {}
574 self.manyEvents = manyEvents
575
576 for i in xrange(-2, nWorkers) :
577 self.d[ i ] = SyncMini( Event(), lastEvent=Event() )
578 if self.manyEvents :
579 self.limitFirst = firstEvent
580
581 self.keys = self.d.keys()
582 self.nWorkers = nWorkers
583 self.log = log
584
GaudiMP.pTools.Syncer.limit
limit
Definition: pTools.py:571
GaudiMP.pTools.Syncer.keys
keys
Definition: pTools.py:581
GaudiMP.pTools.Syncer.d
d
Definition: pTools.py:573
GaudiMP.pTools.SyncMini
Definition: pTools.py:538
GaudiMP.pTools.Syncer.nWorkers
nWorkers
Definition: pTools.py:582
GaudiMP.pTools.Syncer.step
step
Definition: pTools.py:572
GaudiMP.pTools.Syncer.manyEvents
manyEvents
Definition: pTools.py:574
GaudiMP.pTools.Syncer.log
log
Definition: pTools.py:583
GaudiMP.pTools.Syncer.limitFirst
limitFirst
Definition: pTools.py:579

## Member Function Documentation

def GaudiMP.pTools.Syncer.checkAll | ( |  | self | ) |

Definition at line 674 of file pTools.py.

674 def checkAll( self ) :
675 # Check the status of each Sync object
676 # return True or False
677 currentStatus = [ mini.check() for mini in self.d.values() ]
678 return all( currentStatus )
679
GaudiMP.pTools.Syncer.checkAll
def checkAll(self)
Definition: pTools.py:674

def GaudiMP.pTools.Syncer.checkLastEvents | ( |  | self | ) |

Definition at line 680 of file pTools.py.

680 def checkLastEvents( self ) :
681 # check if all of the lastEvents are set to true in self.d[k][1]
682 stat = [ sMini.checkLast() for sMini in self.d.values() ]
683 return all(stat)
684
685 # =========================== Methods =========================================
686
GaudiMP.pTools.Syncer.checkLastEvents
def checkLastEvents(self)
Definition: pTools.py:680

def GaudiMP.pTools.Syncer.processHang | ( |  | self | ) |

Definition at line 668 of file pTools.py.

668 def processHang( self ) :
669 self.log.critical('Some proc is hanging during Event processing!')
670 for k in self.keys :
671 self.log.critical( "Proc/Stat : %i / %s"%(k,self.d[k].check()) )
672 return
673
validate_patch.check
def check(path)
Definition: validate_patch.py:152
GaudiMP.pTools.Syncer.keys
keys
Definition: pTools.py:581
GaudiMP.pTools.Syncer.d
d
Definition: pTools.py:573
GaudiMP.pTools.Syncer.processHang
def processHang(self)
Definition: pTools.py:668

def GaudiMP.pTools.Syncer.syncAll | ( |  | self,
|  |  | step = `"Not specified"`
| ) |  |

Definition at line 585 of file pTools.py.

585 def syncAll( self, step="Not specified" ) :
586 # is it this method, or is it the rolling version needed?
587 # if so, drop through...
588
589 if self.manyEvents :
590 sc = self.syncAllRolling( )
591 return sc
592
593 # Regular version ----------------------------
594 for i in xrange( 0, self.limit, self.step ) :
595 if self.checkAll( ) :
596 self.log.info('%s : All procs done @ %i s'%(step,i))
597 break
598 else :
599 time.sleep(self.step)
600
601 # Now the time limit is up... check the status one final time
602 if self.checkAll() :
603 self.log.info("All processes : %s ok."%(step))
604 return SUCCESS
605 else :
606 self.log.critical('Some process is hanging on : %s'%(step))
607 for k in self.keys :
608 hangString= "%s : Proc/Stat : %i/%s"%(step,k,self.d[k].check())
609 self.log.critical( hangString )
610 return FAILURE
611
GaudiMP.pTools.Syncer.checkAll
def checkAll(self)
Definition: pTools.py:674
GaudiMP.pTools.Syncer.limit
limit
Definition: pTools.py:571
GaudiMP.pTools.Syncer.syncAllRolling
def syncAllRolling(self)
Definition: pTools.py:612
validate_patch.check
def check(path)
Definition: validate_patch.py:152
GaudiMP.pTools.Syncer.keys
keys
Definition: pTools.py:581
GaudiMP.pTools.Syncer.d
d
Definition: pTools.py:573
GaudiMP.pTools.Syncer.step
step
Definition: pTools.py:572
GaudiMP.pTools.Syncer.manyEvents
manyEvents
Definition: pTools.py:574
GaudiMP.pTools.Syncer.syncAll
def syncAll
Definition: pTools.py:585

def GaudiMP.pTools.Syncer.syncAllRolling | ( |  | self | ) |

Definition at line 612 of file pTools.py.

612 def syncAllRolling( self ) :
613 # Keep track of the progress of Event processing
614 # Each process syncs after each event, so keep clearing
615 # the sync Event, and re-checking
616 # Note the time between True checks too, if the time
617 # between events exceeds singleEvent, this is considered a hang
618
619 # set the initial time
620 begin = time.time()
621 firstEv = {}
622 timers = {}
623 for k in self.keys :
624 self.d[k].reset()
625 firstEv[k] = False
626 timers[k] = 0.0
627
628 active = self.keys
629 while True :
630 # check the status of each sync object
631 for k in active :
632 sMini = self.d[k]
633
634 if sMini.check() or sMini.checkLast():
635 if sMini.checkLast() and sMini.check() :
636 # if last Event set,then event loop finished
637 active.remove( k )
638 alive = time.time()-begin
639 self.log.info( "Audit : Node %i alive for %5.2f"\
640 %(k,alive) )
641 else :
642 sMini.reset()
643 else :
644 # the event still has not been checked, how long is that?
645 # is it the first Event?
646 wait = time.time()-sMini.getTime()
647 cond = wait > self.limit
648 if not firstEv[k] :
649 cond = wait > self.limitFirst
650 firstEv[k] = True
651 if cond :
652 # It is hanging!
653 self.log.critical('Single event wait : %5.2f'%(wait))
654 self.processHang()
655 return FAILURE
656
657 # Termination Criteria : if all procs have been removed, we're done
658 if self.checkLastEvents() :
659 self.log.info('TC met for event loop')
660 break
661 else :
662 # sleep, loop again
663 time.sleep(self.step)
664
665 self.log.info("All processes Completed all Events ok")
666 return SUCCESS
667
GaudiMP.pTools.Syncer.checkLastEvents
def checkLastEvents(self)
Definition: pTools.py:680
GaudiMP.pTools.Syncer.limit
limit
Definition: pTools.py:571
GaudiMP.pTools.Syncer.syncAllRolling
def syncAllRolling(self)
Definition: pTools.py:612
GaudiMP.pTools.Syncer.keys
keys
Definition: pTools.py:581
GaudiMP.pTools.Syncer.d
d
Definition: pTools.py:573
GaudiMP.pTools.Syncer.processHang
def processHang(self)
Definition: pTools.py:668
GaudiMP.pTools.Syncer.step
step
Definition: pTools.py:572
GaudiMP.pTools.Syncer.limitFirst
limitFirst
Definition: pTools.py:579

## Member Data Documentation

GaudiMP.pTools.Syncer.d

Definition at line 573 of file pTools.py.

GaudiMP.pTools.Syncer.keys

Definition at line 581 of file pTools.py.

GaudiMP.pTools.Syncer.limit

Definition at line 571 of file pTools.py.

GaudiMP.pTools.Syncer.limitFirst

Definition at line 579 of file pTools.py.

GaudiMP.pTools.Syncer.log

Definition at line 583 of file pTools.py.

GaudiMP.pTools.Syncer.manyEvents

Definition at line 574 of file pTools.py.

GaudiMP.pTools.Syncer.nWorkers

Definition at line 582 of file pTools.py.

GaudiMP.pTools.Syncer.step

Definition at line 572 of file pTools.py.

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

- GaudiMP/python/GaudiMP/pTools.py