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 
def alarm_handler(signum, frame)
Definition: watchdog.py:15

◆ launch()

def watchdog.launch (   args)

Definition at line 25 of file watchdog.py.

References log(), and str.

Referenced by main().

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 
def log(s)
Definition: watchdog.py:21
def launch(args)
Definition: watchdog.py:25
#define str(s)

◆ log()

def watchdog.log (   s)

Definition at line 21 of file watchdog.py.

Referenced by launch(), and main().

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

◆ main()

def watchdog.main (   args)

Definition at line 64 of file watchdog.py.

References launch(), and log().

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 
def log(s)
Definition: watchdog.py:21
def main(args)
Definition: watchdog.py:64
def launch(args)
Definition: watchdog.py:25

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

Definition at line 83 of file watchdog.py.

◆ 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 MuonPFAnalyzer.analyze(), emtf::phase2::algo::TrackBuildingLayer.attachSegments(), edm::EventProcessor.beginJob(), edm::EventProcessor.beginRunAsync(), ExternalLHEProducer.beginRunProduce(), FastTimerService::PlotsPerJob.book(), MuonPFAnalyzer.bookHistos(), CSCWireTopology.channel(), ProcessorBase< GoldenPatternType >.configure(), LateralityCoarsedProvider.convertString(), EcalShowerContainmentCorrections.correctionCoefficients(), EcalShowerContainmentCorrections.correctionXY(), evf::GlobalEvFOutputEventWriter.doOutputEventAsync(), edm::Worker.doWorkAsync(), edm::Worker.doWorkNoPrefetchingAsync(), PatternGenerator.endJob(), edm::EventProcessor.endJob(), edm::Worker::RunModuleTask< T >.execute(), 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(), OMTFConfiguration.getPatternGroups(), MuonPFAnalyzer.getPlot(), SiStripPsuDetIdMap.getPSUName(), HcalTBNumberingScheme.getUnitID(), GenWeightsTableProducer.globalBeginLuminosityBlock(), PatternGenerator.groupPatterns(), edm::EventProcessor.handleNextEventForStreamAsync(), edm::EventProcessor.init(), HcalTestAnalysis.layerGrouping(), SimpleNavigationSchool.linkForwardLayers(), SimpleNavigationSchool.linkNextLayerInGroup(), SimpleNavigationSchool.linkOuterGroup(), SimpleNavigationSchool.linkWithinGroup(), GenObject.GenObject.loadConfigFile(), edm::eventsetup::CallbackExternalWork< T, TAcquireFunc, TAcquireReturn, TProduceFunc, TProduceReturn, TRecord, TDecorator >.makeAcquireTask(), edm::eventsetup::CallbackExternalWork< T, TAcquireFunc, TAcquireReturn, TProduceFunc, TProduceReturn, TRecord, TDecorator >.makeExceptionHandlerTask(), edm::eventsetup::CallbackBase< T, TProduceFunc, TProduceReturn, TRecord, TDecorator >.makeProduceTask(), mergeLHE.DefaultLHEMerger.merge(), mergeLHE.DefaultLHEMerger.merge_headers(), NanoAODDQM.NanoAODDQM(), L1CaloEcalScaleConfigOnlineProd.newObject(), edm::EventProcessor.nextTransitionTypeAsync(), MeasurementByLayerGrouper.operator()(), SimpleNavigationSchool.outerRadiusIncrease(), FastTimerService.postBeginJob(), FastTimerService.postEvent(), edm::eventsetup::Callback< T, TProduceFunc, TReturn, TRecord, TDecorator >.prefetchAsync(), edm::eventsetup::CallbackExternalWork< T, TAcquireFunc, TAcquireReturn, TProduceFunc, TProduceReturn, TRecord, TDecorator >.prefetchAsync(), edm::eventsetup::CallbackBase< T, TProduceFunc, TProduceReturn, TRecord, TDecorator >.prefetchAsyncImpl(), edm::eventsetup::ESSourceProductResolverBase.prefetchAsyncImplTemplate(), edm::Worker.prePrefetchSelectionAsync(), FastTimerService.printEvent(), FastTimerService.printSummary(), PixelTemplateSmearerBase.process(), edm::StreamSchedule.processOneStreamAsync(), HcalTTPDigiProducer.produce(), cms::cuda::impl::ScopedContextHolderHelper.pushNextTask(), HcalTestAnalysis.qieAnalysis(), edm::EventProcessor.readAndMergeLumiEntriesAsync(), edm::EventProcessor.readAndMergeRunEntriesAsync(), EcalWeightGroupXMLTranslator.readXML(), TauDiscriminatorTools.recoTauTypeMapper(), L1MuDTTrackAssembler.runAddressAssignment1(), L1MuBMTrackAssembler.runAddressAssignment1(), L1MuDTTrackAssembler.runAddressAssignment2(), L1MuBMTrackAssembler.runAddressAssignment2(), hippyaddtobaddatafiles.runcfg(), L1MuBMTrackAssembler.runEncoderSubUnit1(), L1MuDTTrackAssembler.runEncoderSubUnit1(), L1MuBMTrackAssembler.runEncoderSubUnit2(), L1MuDTTrackAssembler.runEncoderSubUnit2(), edm::eventsetup::EventSetupsController.runOrQueueEventSetupForInstanceAsync(), jsoncollector::DataPointDefinition.setDefaultGroup(), Key.setGroup(), DD4hep_TrackingMaterialAnalyser.split(), TrackingMaterialAnalyser.split(), LA_Filler_Fitter.summarize_ensembles(), edm.syncWait(), edm::NoProcessProductResolver.tryPrefetchResolverAsync(), 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.