The Gaudi Framework  v31r0 (aeb156f0)
GaudiMP.pTools.Syncer Class Reference
Inheritance diagram for GaudiMP.pTools.Syncer:
Collaboration diagram for GaudiMP.pTools.Syncer:

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 591 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 598 of file pTools.py.

598  firstEvent=None):
599  # Class to help synchronise the sub-processes
600  self.limit = limit
601  self.step = step
602  self.d = {}
603  self.manyEvents = manyEvents
604 
605  for i in xrange(-2, nWorkers):
606  self.d[i] = SyncMini(Event(), lastEvent=Event())
607  if self.manyEvents:
608  self.limitFirst = firstEvent
609 
610  self.keys = self.d.keys()
611  self.nWorkers = nWorkers
612  self.log = log
613 

Member Function Documentation

def GaudiMP.pTools.Syncer.checkAll (   self)

Definition at line 704 of file pTools.py.

704  def checkAll(self):
705  # Check the status of each Sync object
706  # return True or False
707  currentStatus = [mini.check() for mini in self.d.values()]
708  return all(currentStatus)
709 
def checkAll(self)
Definition: pTools.py:704
def GaudiMP.pTools.Syncer.checkLastEvents (   self)

Definition at line 710 of file pTools.py.

710  def checkLastEvents(self):
711  # check if all of the lastEvents are set to true in self.d[k][1]
712  stat = [sMini.checkLast() for sMini in self.d.values()]
713  return all(stat)
714 
715 
716 # =========================== Methods =========================================
717 
718 
def checkLastEvents(self)
Definition: pTools.py:710
def GaudiMP.pTools.Syncer.processHang (   self)

Definition at line 698 of file pTools.py.

698  def processHang(self):
699  self.log.critical('Some proc is hanging during Event processing!')
700  for k in self.keys:
701  self.log.critical("Proc/Stat : %i / %s" % (k, self.d[k].check()))
702  return
703 
def processHang(self)
Definition: pTools.py:698
def GaudiMP.pTools.Syncer.syncAll (   self,
  step = "Not specified" 
)

Definition at line 614 of file pTools.py.

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

Definition at line 642 of file pTools.py.

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

Member Data Documentation

GaudiMP.pTools.Syncer.d

Definition at line 602 of file pTools.py.

GaudiMP.pTools.Syncer.keys

Definition at line 610 of file pTools.py.

GaudiMP.pTools.Syncer.limit

Definition at line 600 of file pTools.py.

GaudiMP.pTools.Syncer.limitFirst

Definition at line 608 of file pTools.py.

GaudiMP.pTools.Syncer.log

Definition at line 612 of file pTools.py.

GaudiMP.pTools.Syncer.manyEvents

Definition at line 603 of file pTools.py.

GaudiMP.pTools.Syncer.nWorkers

Definition at line 611 of file pTools.py.

GaudiMP.pTools.Syncer.step

Definition at line 601 of file pTools.py.


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