+
+import threading
+
+class TaskRunnerThread(threading.Thread):
+ def __init__(self, taskRunner, callback=None):
+ self.taskRunner = taskRunner
+ self.startTime = None
+ self.stopTime = None
+ self.callback = callback
+ threading.Thread.__init__ ( self )
+
+ def run(self):
+ self.startTime = time.time()
+ self.taskRunner.run()
+ self.stopTime = time.time()
+ #if self.callback:
+ # self.callback
+
+ def elapsedTime(self):
+ now = self.stopTime
+ if not now:
+ now = time.time()
+ elapsed_time = now-self.startTime
+ mins = elapsed_time/60
+ hours = mins/60
+ seconds = (elapsed_time - mins) % 60
+ return "%d:%d:%d" % (hours, mins, seconds)
+
+ def totalTime(self):
+ if self.stopTime:
+ return self.elapsedTime()
+ else:
+ return None
+