summaryrefslogtreecommitdiff
path: root/buildstream/_scheduler/scheduler.py
diff options
context:
space:
mode:
authorTristan Van Berkom <tristan.vanberkom@codethink.co.uk>2018-04-01 20:42:50 +0900
committerTristan Van Berkom <tristan.vanberkom@codethink.co.uk>2018-04-01 20:50:59 +0900
commit63d9946357d655b0af56202d4fba37ae3f8c5f06 (patch)
treeb310f8db43c6a9832869094e9de2bb31c76bb393 /buildstream/_scheduler/scheduler.py
parentb9546d4de7447e2f013cd263151d5d4a596e2dfe (diff)
downloadbuildstream-63d9946357d655b0af56202d4fba37ae3f8c5f06.tar.gz
Include initialization time in the total session time of the build log
This patch refactors the frontend App object and touches a few internals. o The scheduler now takes a start time given to it at instantiation time, instead of considering the start time to commence in Scheduler.run() o The App.initialize() method has been swapped out for an App.initialized() context manager. This context manager now takes care of the main start/fail/success messages. For convenience and ensured consistency, this context manager is now responsible for: o Printing the startup heading o Printing the end of session summary o Exiting with a consistent error status in case of errors o The Pipeline() object no longer prints the start/fail/success messages, as they are now taken care of by the App() o The cli.py frontend code is much simplified by using the new context manager, also enforcing consistency in how we handle and report errors. This fixes issue #186
Diffstat (limited to 'buildstream/_scheduler/scheduler.py')
-rw-r--r--buildstream/_scheduler/scheduler.py6
1 files changed, 3 insertions, 3 deletions
diff --git a/buildstream/_scheduler/scheduler.py b/buildstream/_scheduler/scheduler.py
index 574cabc83..84f538f3d 100644
--- a/buildstream/_scheduler/scheduler.py
+++ b/buildstream/_scheduler/scheduler.py
@@ -51,6 +51,7 @@ class SchedStatus():
#
# Args:
# context: The Context in the parent scheduling process
+# start_time: The time at which the session started
# interrupt_callback: A callback to handle ^C
# ticker_callback: A callback call once per second
# job_start_callback: A callback call when each job starts
@@ -59,6 +60,7 @@ class SchedStatus():
class Scheduler():
def __init__(self, context,
+ start_time,
interrupt_callback=None,
ticker_callback=None,
job_start_callback=None,
@@ -70,7 +72,7 @@ class Scheduler():
self.job_complete_callback = job_complete_callback
self.context = context
self.queues = None
- self.starttime = None
+ self.starttime = start_time
self.suspendtime = None
# Initialize task tokens with the number allowed by
@@ -102,8 +104,6 @@ class Scheduler():
#
def run(self, queues):
- self.starttime = datetime.datetime.now()
-
# Attach the queues
self.queues = queues
for queue in queues: