11 #include "GaudiKernel/WatchdogThread.h"
12 #include "GaudiKernel/IIncidentSvc.h"
13 #include "GaudiKernel/Memory.h"
24 const std::string &
name,
25 boost::posix_time::time_duration timeout,
26 bool stackTrace =
false,
28 bool autostart =
false):
32 m_stackTrace(stackTrace){}
33 ~EventWatchdog()
override =
default;
42 bool m_stackTrace =
false;
47 <<
"s since the last " << IncidentType::BeginEvent <<
endmsg;
52 log <<
MSG::INFO <<
"Current memory usage is"
56 if (m_stackTrace && gSystem) {
58 std::cerr <<
"=== Stalled event: current stack trace ===" << std::endl;
59 gSystem->StackTrace();
62 if (m_maxCount > 0 && m_counter >= m_maxCount) {
63 log <<
MSG::FATAL <<
"too much time on a single event: aborting process" <<
endmsg;
70 log <<
MSG::INFO <<
"Starting a new event after ~"
77 log <<
MSG::INFO <<
"The last event took ~"
88 "Number of seconds allowed to process a single event (0 to disable the check).");
91 "Number timeouts before aborting the execution (0 means never abort).");
93 declareProperty(
"StackTrace", m_stackTrace =
false,
94 "Whether to print the stack-trace on timeout.");
112 static const std::string serviceName =
"IncidentSvc";
115 error() <<
"Cannot retrieve " << serviceName <<
endmsg;
118 debug() <<
"Register to the IncidentSvc" <<
endmsg;
121 warning() <<
"StalledEventMonitor/" <<
name()
122 <<
" instantiated with 0 time-out: no monitoring performed" <<
endmsg;
152 return base_class::finalize();
Definition of the MsgStream class used to transmit messages.
The ISvcLocator is the interface implemented by the Service Factory in the Application Manager to loc...
StatusCode stop() override
Stop the watchdog thread (after the event loop).
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
boost::posix_time::time_duration getTimeout() const
Get the current time-out value.
virtual void onStop()
User implemented function that will be called when stopping.
std::unique_ptr< WatchdogThread > m_watchdog
Pointer to the watchdog thread that checks for the event timeout.
void handle(const Incident &) override
Notify the watchdog thread for a new event.
StatusCode start() override
Start the watchdog thread (before entering the event loop).
bool isFailure() const
Test for a status code of FAILURE.
GAUDI_API long virtualMemory(MemoryUnit unit=kByte, InfoType fetch=Memory, long pid=-1)
Basic Process Information: priority boost.
Service that monitor the time taken by processing of single events using a separate thread...
SmartIF< IIncidentSvc > m_incidentSvc
Pointer to the incident service.
This class is used for returning status codes from appropriate routines.
#define DECLARE_COMPONENT(type)
int m_maxTimeoutCount
Number timeouts before aborting the execution (0 means never abort).
unsigned int m_eventTimeout
Number of seconds allowed to process a single event.
StalledEventMonitor(const std::string &name, ISvcLocator *svcLoc)
Constructor.
virtual void onPing()
User implemented function that will be called when ping is called.
StatusCode initialize() override
Initialization of the service.
Simple class for asynchronous check of time-out.
Base class used to extend a class implementing other interfaces.
GAUDI_API long pagedMemory(MemoryUnit unit=kByte, InfoType fetch=Memory, long pid=-1)
Basic Process Information: Amount of paged memory currently occupied by the process 'pid'...
Base class for all Incidents (computing events).
virtual void addListener(IIncidentListener *lis, const std::string &type="", long priority=0, bool rethrow=false, bool singleShot=false)=0
Add listener.
StatusCode finalize() override
Finalization of the service.
void reset(TYPE *ptr=nullptr)
Set the internal pointer to the passed one disposing of the old one.
virtual void removeListener(IIncidentListener *lis, const std::string &type="")=0
Remove listener.
virtual void action()
User implemented function that will be called if the time-out is reached.