3from AthenaCommon
import Logging
8logger = Logging.logging.getLogger(
"PowhegControl")
12 """! Helper class to run repeating timing output in an additional thread.
14 @author http://stackoverflow.com/questions/5429577/
18 """! Override Thread.run with desired behaviour."""
21 if self.finished.is_set():
28 """! Return duration in a human-readable form.
30 @param duration Time interval to print.
32 if not isinstance(duration, datetime.timedelta):
33 duration = datetime.timedelta(seconds=duration)
34 h, m, s = str(duration).
split(
":")
36 return "{}h {:>02}m {:>02}s".format(h, m, int(float(s)))
38 return "{}m {:>02}s".format(int(float(m)), int(float(s)))
39 return "{:.2f}s".format(float(s))
43 """! Recurring heartbeat that emits a message to console and to file.
45 @author James Robinson <james.robinson@cern.ch>
48 def __init__(self, interval, output_file=None):
51 @param interval Time interval between output messages in seconds.
52 @param output_file Log file to write to.
59 """! Output a heartbeat message."""
60 duration = RepeatingTimer.readable_duration(datetime.datetime.now() - self.
start_time)
61 message =
"Heartbeat: Powheg generation has been running for {} in total".format(duration)
67 except IOError
as detail:
68 logger.error(
"I/O error: {}".format(detail))
Recurring heartbeat that emits a message to console and to file.
__init__(self, interval, output_file=None)
Constructor.
__emit_heartbeat(self)
Output a heartbeat message.
Helper class to run repeating timing output in an additional thread.
readable_duration(duration)
Return duration in a human-readable form.
std::vector< std::string > split(const std::string &s, const std::string &t=":")