3 from AthenaCommon
import Logging
8 logger = 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."""
20 self.finished.wait(self.interval)
21 if self.finished.is_set():
24 self.function(*self.args, **self.kwargs)
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)
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))