CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
Classes | Functions | Variables
watchdog Namespace Reference

Classes

class  Timeout
 

Functions

def alarm_handler
 
def launch
 
def log
 
def main
 

Variables

tuple args = parser.parse_args()
 
tuple group = parser.add_mutually_exclusive_group()
 
tuple parser = argparse.ArgumentParser(description="Kill/restart the child process if it doesn't out the required string.")
 
tuple stdin_ = os.dup(sys.stdin.fileno())
 
tuple stdout_ = os.dup(sys.stdout.fileno())
 

Function Documentation

def watchdog.alarm_handler (   signum,
  frame 
)

Definition at line 15 of file watchdog.py.

15 
16 def alarm_handler(signum, frame):
17  if signum != 14: return
18  raise Timeout("Timeout reached.")
19 
20 signal.signal(signal.SIGALRM, alarm_handler)
def alarm_handler
Definition: watchdog.py:15
def watchdog.launch (   args)

Definition at line 25 of file watchdog.py.

References log().

Referenced by main().

25 
26 def launch(args):
27  fd, wd = os.pipe()
28 
29  def preexec():
30  os.close(fd)
31 
32  env = os.environ
33  env["WATCHDOG_FD"] = str(wd)
34 
35  p = subprocess.Popen(args.pargs, preexec_fn=preexec, stdin=stdin_, stdout=stdout_)
36  os.close(wd)
37 
38  while True:
39  try:
40  signal.alarm(args.t)
41  ch = os.read(fd, 1024)
42  signal.alarm(0)
43 
44  if not ch:
45  os.close(fd)
46  return False, p.wait() # normal exit
47 
48  log("Received: %s, timer reset." % repr(ch))
49 
50  except Timeout, t:
51  signal.alarm(0)
52 
53  log("Timeout reached, taking action.")
54 
55  if p.poll() is None:
56  p.send_signal(args.action)
57 
58  os.close(fd)
59  return True, p.wait()
60 
61  for p in open_procs_:
62  if p.poll() is None:
63  p.send_signal(sig)
def launch
Definition: watchdog.py:25
def log
Definition: watchdog.py:21
def watchdog.log (   s)

Definition at line 21 of file watchdog.py.

Referenced by launch(), and main().

21 
22 def log(s):
23  sys.stderr.write("watchdog: " + s + "\n");
24  sys.stderr.flush()
def log
Definition: watchdog.py:21
def watchdog.main (   args)

Definition at line 64 of file watchdog.py.

References launch(), and log().

64 
65 def main(args):
66  while True:
67  killed, ret = launch(args)
68  log("Program exitted, killed: %s, code: %d." % (killed, ret, ))
69 
70  if killed and args.restart:
71  log("Restarting.")
72  continue
73 
74  break
75 
def launch
Definition: watchdog.py:25
def log
Definition: watchdog.py:21
def main
Definition: watchdog.py:64

Variable Documentation

tuple watchdog.args = parser.parse_args()

Definition at line 87 of file watchdog.py.

tuple watchdog.group = parser.add_mutually_exclusive_group()

Definition at line 82 of file watchdog.py.

Referenced by MuonPFAnalyzer.analyze(), MuonPFAnalyzer.bookHistos(), CSCWireTopology.channel(), EcalShowerContainmentCorrections.correctionCoefficients(), EcalShowerContainmentCorrections.correctionXY(), SimG4HcalValidation.fetchHits(), HcalTB04Analysis.fillBuffer(), EcalShowerContainmentCorrections.fillCorrectionCoefficients(), HcalTB04Analysis.fillEvent(), HcalTestHistoClass.fillHits(), HcalTB04Analysis.finalAnalysis(), contentValuesLib.getDatasetName(), HcalTBNumberingScheme.getUnitID(), SimpleNavigationSchool.linkForwardLayers(), L1CaloEcalScaleConfigOnlineProd.newObject(), MeasurementByLayerGrouper.operator()(), HcalTTPDigiProducer.produce(), HcalTestAnalysis.qieAnalysis(), EcalWeightGroupXMLTranslator.readXML(), TauDiscriminatorTools.recoTauTypeMapper(), L1MuDTTrackAssembler.runEncoderSubUnit1(), L1MuDTTrackAssembler.runEncoderSubUnit2(), roll_playback.sanity_check(), jsoncollector::DataPointDefinition.setDefaultGroup(), TrackingMaterialAnalyser.split(), LA_Filler_Fitter.summarize_ensembles(), and HcalTB04Analysis.unitID().

tuple watchdog.parser = argparse.ArgumentParser(description="Kill/restart the child process if it doesn't out the required string.")

Definition at line 76 of file watchdog.py.

tuple watchdog.stdin_ = os.dup(sys.stdin.fileno())

Definition at line 7 of file watchdog.py.

tuple watchdog.stdout_ = os.dup(sys.stdout.fileno())

Definition at line 8 of file watchdog.py.