summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJames Ennis <james.ennis@codethink.co.uk>2019-08-30 14:49:58 +0100
committerbst-marge-bot <marge-bot@buildstream.build>2019-09-04 12:05:49 +0000
commit566a6a55d5d3c73809d6e43d819fa36702f0c231 (patch)
tree4476bd60a39a3cafb0b07cec710dbf96257ca9a9
parent1edb7fc296f8c23164d7df90914260b2089bbe8a (diff)
downloadbuildstream-566a6a55d5d3c73809d6e43d819fa36702f0c231.tar.gz
_messenger.py: Don't display subtask information before 3 seconds
Prior to this patch, subtask information was always displayed, regardless of how long it took. Now, I've implemented a _DISPLAY_LIMIT of 3 seconds. If a task takes longer than 3 seconds, the subtask information will be printed.
-rw-r--r--src/buildstream/_messenger.py13
1 files changed, 10 insertions, 3 deletions
diff --git a/src/buildstream/_messenger.py b/src/buildstream/_messenger.py
index be5f12c0a..f5f570319 100644
--- a/src/buildstream/_messenger.py
+++ b/src/buildstream/_messenger.py
@@ -30,6 +30,13 @@ from ._message import Message, MessageType
_RENDER_INTERVAL = datetime.timedelta(seconds=1)
+# Time in seconds for which we decide that we want to display subtask information
+_DISPLAY_LIMIT = datetime.timedelta(seconds=3)
+# If we're in the test suite, we need to ensure that we don't set a limit
+if "BST_TEST_SUITE" in os.environ:
+ _DISPLAY_LIMIT = datetime.timedelta(seconds=0)
+
+
# TimeData class to contain times in an object that can be passed around
# and updated from different places
class _TimeData():
@@ -224,13 +231,13 @@ class Messenger():
self._next_render = None
elapsed = datetime.datetime.now() - timedata.start_time
- if task.current_progress is not None:
+ detail = None
+
+ if task.current_progress is not None and elapsed > _DISPLAY_LIMIT:
if task.maximum_progress is not None:
detail = "{} of {} subtasks processed".format(task.current_progress, task.maximum_progress)
else:
detail = "{} subtasks processed".format(task.current_progress)
- else:
- detail = None
message = Message(MessageType.SUCCESS, activity_name, elapsed=elapsed, detail=detail,
element_name=element_name)
self.message(message)