CMS 3D CMS Logo

Classes | Functions | Variables
watchdog Namespace Reference

Classes

class  Timeout
 

Functions

def alarm_handler (signum, frame)
 
def launch (args)
 
def log (s)
 
def main (args)
 

Variables

 action
 
 args
 
 const
 
 default
 
 description
 
 dest
 
 False
 
 group
 
 help
 
 int
 
 nargs
 
 parser
 
 SIGTERM
 
 stdin_
 
 stdout_
 
 type
 

Function Documentation

◆ alarm_handler()

def watchdog.alarm_handler (   signum,
  frame 
)

Definition at line 15 of file watchdog.py.

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

◆ launch()

def watchdog.launch (   args)

Definition at line 25 of file watchdog.py.

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

References log(), and str.

Referenced by main().

◆ log()

def watchdog.log (   s)

Definition at line 21 of file watchdog.py.

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

Referenced by launch(), and main().

◆ main()

def watchdog.main (   args)

Definition at line 64 of file watchdog.py.

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

References launch(), and log().

Variable Documentation

◆ action

watchdog.action

Definition at line 79 of file watchdog.py.

◆ args

watchdog.args

Definition at line 87 of file watchdog.py.

◆ const

watchdog.const

◆ default

watchdog.default

Definition at line 77 of file watchdog.py.

◆ description

watchdog.description

Definition at line 76 of file watchdog.py.

◆ dest

watchdog.dest

Definition at line 83 of file watchdog.py.

◆ False

watchdog.False

Definition at line 79 of file watchdog.py.

◆ group

watchdog.group

Definition at line 82 of file watchdog.py.

Referenced by alignment.Alignment.__getConditions(), MuonPFAnalyzer.analyze(), FastTimerService::PlotsPerJob.book(), MuonPFAnalyzer.bookHistos(), CSCWireTopology.channel(), EcalShowerContainmentCorrections.correctionCoefficients(), EcalShowerContainmentCorrections.correctionXY(), SimG4HcalValidation.fetchHits(), FastTimerService::PlotsPerJob.fill(), HcalTB04Analysis.fillBuffer(), EcalShowerContainmentCorrections.fillCorrectionCoefficients(), HcalTB04Analysis.fillEvent(), HcalTestHistoClass.fillHits(), HcalTB04Analysis.finalAnalysis(), utils.get_relval_id(), contentValuesLib.getDatasetName(), SiStripPsuDetIdMap.getDetectorLocation(), RPCAMCLinkEvent.getId(), MuonPFAnalyzer.getPlot(), SiStripPsuDetIdMap.getPSUName(), HcalTBNumberingScheme.getUnitID(), HcalTestAnalysis.layerGrouping(), SimpleNavigationSchool.linkForwardLayers(), SimpleNavigationSchool.linkNextLayerInGroup(), SimpleNavigationSchool.linkOuterGroup(), SimpleNavigationSchool.linkWithinGroup(), GenObject.GenObject.loadConfigFile(), NanoAODDQM.NanoAODDQM(), L1CaloEcalScaleConfigOnlineProd.newObject(), MeasurementByLayerGrouper.operator()(), SimpleNavigationSchool.outerRadiusIncrease(), FastTimerService.postBeginJob(), FastTimerService.postEvent(), FastTimerService.printEvent(), FastTimerService.printSummary(), PixelTemplateSmearerBase.process(), HcalTTPDigiProducer.produce(), HcalTestAnalysis.qieAnalysis(), EcalWeightGroupXMLTranslator.readXML(), TauDiscriminatorTools.recoTauTypeMapper(), L1MuBMTrackAssembler.runAddressAssignment1(), L1MuDTTrackAssembler.runAddressAssignment1(), L1MuBMTrackAssembler.runAddressAssignment2(), L1MuDTTrackAssembler.runAddressAssignment2(), hippyaddtobaddatafiles.runcfg(), L1MuBMTrackAssembler.runEncoderSubUnit1(), L1MuDTTrackAssembler.runEncoderSubUnit1(), L1MuBMTrackAssembler.runEncoderSubUnit2(), L1MuDTTrackAssembler.runEncoderSubUnit2(), jsoncollector::DataPointDefinition.setDefaultGroup(), DD4hep_TrackingMaterialAnalyser.split(), TrackingMaterialAnalyser.split(), GenWeightsTableProducer.streamBeginLuminosityBlock(), LA_Filler_Fitter.summarize_ensembles(), and HcalTB04Analysis.unitID().

◆ help

watchdog.help

Definition at line 77 of file watchdog.py.

◆ int

watchdog.int

Definition at line 77 of file watchdog.py.

◆ nargs

watchdog.nargs

Definition at line 80 of file watchdog.py.

◆ parser

watchdog.parser

Definition at line 76 of file watchdog.py.

◆ SIGTERM

watchdog.SIGTERM

◆ stdin_

watchdog.stdin_

Definition at line 7 of file watchdog.py.

◆ stdout_

watchdog.stdout_

Definition at line 8 of file watchdog.py.

◆ type

watchdog.type

Definition at line 77 of file watchdog.py.

watchdog.main
def main(args)
Definition: watchdog.py:64
str
#define str(s)
Definition: TestProcessor.cc:48
ecaldqm::Timeout
Definition: FEFlags.h:11
watchdog.launch
def launch(args)
Definition: watchdog.py:25
watchdog.log
def log(s)
Definition: watchdog.py:21
watchdog.alarm_handler
def alarm_handler(signum, frame)
Definition: watchdog.py:15