1
0
mirror of https://github.com/ARM-software/workload-automation.git synced 2024-10-06 02:41:11 +01:00

framework/job: track run time.

Job now tracks how long it took to run the workload and save the
timedelta value in the run_time attribute.
This commit is contained in:
Sergei Trofimov 2017-09-15 13:44:20 +01:00
parent 2ef4074c8b
commit 1e233d2104

View File

@ -1,4 +1,5 @@
import logging
from datetime import datetime
from wa.framework import pluginloader, signal
from wa.framework.configuration.core import Status
@ -37,6 +38,7 @@ class Job(object):
self.context = context
self.workload = None
self.output = None
self.run_time = None
self.retries = 0
self._status = Status.NEW
@ -71,7 +73,11 @@ class Job(object):
def run(self, context):
self.logger.info('Running job {}'.format(self.id))
with signal.wrap('WORKLOAD_EXECUTION', self, context):
self.workload.run(context)
start_time = datetime.utcnow()
try:
self.workload.run(context)
finally:
self.run_time = datetime.utcnow() - start_time
def process_output(self, context):
self.logger.info('Processing output for job {}'.format(self.id))