summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAngelos Evripiotis <jevripiotis@bloomberg.net>2019-07-04 16:22:32 +0100
committerbst-marge-bot <marge-bot@buildstream.build>2019-07-05 09:44:45 +0000
commit7b94cd24ca00351cd7ece856ca815bc27038f091 (patch)
tree6c09915a6ce4e9ff5ed271239a05cc79dcd46ae7
parentc58b97794dbbef9398efb1db37ace086d719d974 (diff)
downloadbuildstream-7b94cd24ca00351cd7ece856ca815bc27038f091.tar.gz
_messenger: _message_depth -> _silence_scope_depth
Replace the _message_depth list with an int, "_silence_scope_depth".
-rw-r--r--src/buildstream/_messenger.py27
1 files changed, 10 insertions, 17 deletions
diff --git a/src/buildstream/_messenger.py b/src/buildstream/_messenger.py
index 49eaf3e4c..8764c0288 100644
--- a/src/buildstream/_messenger.py
+++ b/src/buildstream/_messenger.py
@@ -32,7 +32,7 @@ class Messenger():
def __init__(self):
self._message_handler = None
- self._message_depth = []
+ self._silence_scope_depth = 0
self._log_handle = None
self._log_filename = None
@@ -57,7 +57,7 @@ class Messenger():
# (bool): Whether messages are currently being silenced
#
def _silent_messages(self):
- return any(self._message_depth)
+ return self._silence_scope_depth > 0
# message():
#
@@ -87,12 +87,17 @@ class Messenger():
# important messages will not be silenced.
#
@contextmanager
- def silence(self):
- self._push_message_depth(True)
+ def silence(self, silent_nested=True):
+ if not silent_nested:
+ yield
+ return
+
+ self._silence_scope_depth += 1
try:
yield
finally:
- self._pop_message_depth()
+ assert self._silence_scope_depth > 0
+ self._silence_scope_depth -= 1
# timed_activity()
#
@@ -273,15 +278,3 @@ class Messenger():
# Write to the open log file
self._log_handle.write('{}\n'.format(text))
self._log_handle.flush()
-
- # _push_message_depth() / _pop_message_depth()
- #
- # For status messages, send the depth of timed
- # activities inside a given task through the message
- #
- def _push_message_depth(self, silent_nested):
- self._message_depth.append(silent_nested)
-
- def _pop_message_depth(self):
- assert self._message_depth
- self._message_depth.pop()