diff options
author | Angelos Evripiotis <jevripiotis@bloomberg.net> | 2019-07-02 15:01:50 +0100 |
---|---|---|
committer | bst-marge-bot <marge-bot@buildstream.build> | 2019-07-05 09:44:45 +0000 |
commit | b60fffebf563edfe258cbb893754197af1ac5a0b (patch) | |
tree | 48d7a2bee30f9b9edf6ea825bc9b22c804d38e53 /src/buildstream/_context.py | |
parent | fe632514cb1892da1fe0c0f0c3a4fa3d33a8ec50 (diff) | |
download | buildstream-b60fffebf563edfe258cbb893754197af1ac5a0b.tar.gz |
Refactor: message handlers take 'is_silenced'
Remove the need to pass the Context object to message handlers, by
passing what is usually requested from the context instead.
This paves the way to sharing less information with some child jobs -
they won't need the whole context object, just the messenger.
Diffstat (limited to 'src/buildstream/_context.py')
-rw-r--r-- | src/buildstream/_context.py | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/src/buildstream/_context.py b/src/buildstream/_context.py index de1f83d32..8d8509f27 100644 --- a/src/buildstream/_context.py +++ b/src/buildstream/_context.py @@ -438,8 +438,13 @@ class Context(): # Sets the handler for any status messages propagated through # the context. # - # The message handler should have the same signature as - # the message() method + # The handler should have the signature: + # + # def handler( + # message: _message.Message, # The message to send. + # is_silenced: bool, # Whether messages are currently being silenced. + # ) -> None + # def set_message_handler(self, handler): self._messenger.set_message_handler(handler) @@ -460,7 +465,7 @@ class Context(): # message: A Message object # def message(self, message): - self._messenger.message(message, context=self) + self._messenger.message(message) # silence() # @@ -487,7 +492,7 @@ class Context(): @contextmanager def timed_activity(self, activity_name, *, unique_id=None, detail=None, silent_nested=False): with self._messenger.timed_activity( - activity_name, context=self, unique_id=unique_id, detail=detail, silent_nested=silent_nested): + activity_name, unique_id=unique_id, detail=detail, silent_nested=silent_nested): yield # recorded_messages() |