| The Gaudi Framework v29r1 (5cd95fa2)

- 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__ (self, nWorkers, log, manyEvents=False, limit=None, step=None, firstEvent=None)
def | syncAll (self, step="Not specified")
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 588 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 590 of file pTools.py.

590 limit=None, step=None, firstEvent=None):
591 # Class to help synchronise the sub-processes
592 self.limit = limit
593 self.step = step
594 self.d = {}
595 self.manyEvents = manyEvents
596
597 for i in xrange(-2, nWorkers):
598 self.d[i] = SyncMini(Event(), lastEvent=Event())
599 if self.manyEvents:
600 self.limitFirst = firstEvent
601
602 self.keys = self.d.keys()
603 self.nWorkers = nWorkers
604 self.log = log
605
GaudiMP.pTools.Syncer.limit
limit
Definition: pTools.py:592
GaudiMP.pTools.Syncer.keys
keys
Definition: pTools.py:602
GaudiMP.pTools.Syncer.d
d
Definition: pTools.py:594
GaudiMP.pTools.SyncMini
Definition: pTools.py:552
GaudiMP.pTools.Syncer.nWorkers
nWorkers
Definition: pTools.py:603
GaudiMP.pTools.Syncer.step
step
Definition: pTools.py:593
GaudiMP.pTools.Syncer.manyEvents
manyEvents
Definition: pTools.py:595
GaudiMP.pTools.Syncer.log
log
Definition: pTools.py:604
GaudiMP.pTools.Syncer.limitFirst
limitFirst
Definition: pTools.py:600

## Member Function Documentation

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

Definition at line 696 of file pTools.py.

696 def checkAll(self):
697 # Check the status of each Sync object
698 # return True or False
699 currentStatus = [mini.check() for mini in self.d.values()]
700 return all(currentStatus)
701
GaudiMP.pTools.Syncer.checkAll
def checkAll(self)
Definition: pTools.py:696

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

Definition at line 702 of file pTools.py.

702 def checkLastEvents(self):
703 # check if all of the lastEvents are set to true in self.d[k][1]
704 stat = [sMini.checkLast() for sMini in self.d.values()]
705 return all(stat)
706
707 # =========================== Methods =========================================
708
709
GaudiMP.pTools.Syncer.checkLastEvents
def checkLastEvents(self)
Definition: pTools.py:702

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

Definition at line 690 of file pTools.py.

690 def processHang(self):
691 self.log.critical('Some proc is hanging during Event processing!')
692 for k in self.keys:
693 self.log.critical("Proc/Stat : %i / %s" % (k, self.d[k].check()))
694 return
695
GaudiMP.pTools.Syncer.keys
keys
Definition: pTools.py:602
GaudiMP.pTools.Syncer.d
d
Definition: pTools.py:594
GaudiMP.pTools.Syncer.processHang
def processHang(self)
Definition: pTools.py:690

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

Definition at line 606 of file pTools.py.

606 def syncAll(self, step="Not specified"):
607 # is it this method, or is it the rolling version needed?
608 # if so, drop through...
609
610 if self.manyEvents:
611 sc = self.syncAllRolling()
612 return sc
613
614 # Regular version ----------------------------
615 for i in xrange(0, self.limit, self.step):
616 if self.checkAll():
617 self.log.info('%s : All procs done @ %i s' % (step, i))
618 break
619 else:
620 time.sleep(self.step)
621
622 # Now the time limit is up... check the status one final time
623 if self.checkAll():
624 self.log.info("All processes : %s ok." % (step))
625 return SUCCESS
626 else:
627 self.log.critical('Some process is hanging on : %s' % (step))
628 for k in self.keys:
629 hangString = "%s : Proc/Stat : %i/%s" % (
630 step, k, self.d[k].check())
631 self.log.critical(hangString)
632 return FAILURE
633
GaudiMP.pTools.Syncer.checkAll
def checkAll(self)
Definition: pTools.py:696
GaudiMP.pTools.Syncer.limit
limit
Definition: pTools.py:592
GaudiMP.pTools.Syncer.syncAllRolling
def syncAllRolling(self)
Definition: pTools.py:634
GaudiMP.pTools.Syncer.keys
keys
Definition: pTools.py:602
GaudiMP.pTools.Syncer.d
d
Definition: pTools.py:594
GaudiMP.pTools.Syncer.step
step
Definition: pTools.py:593
GaudiMP.pTools.Syncer.syncAll
def syncAll(self, step="Not specified")
Definition: pTools.py:606
GaudiMP.pTools.Syncer.manyEvents
manyEvents
Definition: pTools.py:595

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

Definition at line 634 of file pTools.py.

634 def syncAllRolling(self):
635 # Keep track of the progress of Event processing
636 # Each process syncs after each event, so keep clearing
637 # the sync Event, and re-checking
638 # Note the time between True checks too, if the time
639 # between events exceeds singleEvent, this is considered a hang
640
641 # set the initial time
642 begin = time.time()
643 firstEv = {}
644 timers = {}
645 for k in self.keys:
646 self.d[k].reset()
647 firstEv[k] = False
648 timers[k] = 0.0
649
650 active = self.keys
651 while True:
652 # check the status of each sync object
653 for k in active:
654 sMini = self.d[k]
655
656 if sMini.check() or sMini.checkLast():
657 if sMini.checkLast() and sMini.check():
658 # if last Event set,then event loop finished
659 active.remove(k)
660 alive = time.time() - begin
661 self.log.info("Audit : Node %i alive for %5.2f"
662 % (k, alive))
663 else:
664 sMini.reset()
665 else:
666 # the event still has not been checked, how long is that?
667 # is it the first Event?
668 wait = time.time() - sMini.getTime()
669 cond = wait > self.limit
670 if not firstEv[k]:
671 cond = wait > self.limitFirst
672 firstEv[k] = True
673 if cond:
674 # It is hanging!
675 self.log.critical('Single event wait : %5.2f' % (wait))
676 self.processHang()
677 return FAILURE
678
679 # Termination Criteria : if all procs have been removed, we're done
680 if self.checkLastEvents():
681 self.log.info('TC met for event loop')
682 break
683 else:
684 # sleep, loop again
685 time.sleep(self.step)
686
687 self.log.info("All processes Completed all Events ok")
688 return SUCCESS
689
GaudiMP.pTools.Syncer.checkLastEvents
def checkLastEvents(self)
Definition: pTools.py:702
GaudiMP.pTools.Syncer.limit
limit
Definition: pTools.py:592
GaudiMP.pTools.Syncer.syncAllRolling
def syncAllRolling(self)
Definition: pTools.py:634
GaudiMP.pTools.Syncer.keys
keys
Definition: pTools.py:602
GaudiMP.pTools.Syncer.d
d
Definition: pTools.py:594
GaudiMP.pTools.Syncer.processHang
def processHang(self)
Definition: pTools.py:690
GaudiMP.pTools.Syncer.step
step
Definition: pTools.py:593
GaudiMP.pTools.Syncer.limitFirst
limitFirst
Definition: pTools.py:600

## Member Data Documentation

GaudiMP.pTools.Syncer.d

Definition at line 594 of file pTools.py.

GaudiMP.pTools.Syncer.keys

Definition at line 602 of file pTools.py.

GaudiMP.pTools.Syncer.limit

Definition at line 592 of file pTools.py.

GaudiMP.pTools.Syncer.limitFirst

Definition at line 600 of file pTools.py.

GaudiMP.pTools.Syncer.log

Definition at line 604 of file pTools.py.

GaudiMP.pTools.Syncer.manyEvents

Definition at line 595 of file pTools.py.

GaudiMP.pTools.Syncer.nWorkers

Definition at line 603 of file pTools.py.

GaudiMP.pTools.Syncer.step

Definition at line 593 of file pTools.py.

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

- GaudiMP/python/GaudiMP/pTools.py