diff options
author | bst-marge-bot <marge-bot@buildstream.build> | 2020-07-06 19:47:33 +0000 |
---|---|---|
committer | bst-marge-bot <marge-bot@buildstream.build> | 2020-07-06 19:47:33 +0000 |
commit | 99d827faad1d38e85532e056561a967636cfc4b5 (patch) | |
tree | 55ba99140008a72e9d762b8319613bbbabe586b6 /src/buildstream/_state.py | |
parent | e79f4a019d1d4c23d442f61144e6ac5177eb36b2 (diff) | |
parent | cb2acc31743d6e208a7977288485578ca17effdd (diff) | |
download | buildstream-99d827faad1d38e85532e056561a967636cfc4b5.tar.gz |
Merge branch 'bschubert/simplify-stream-interactions' into 'master'
simplify stream interactions (Remove Notifications)
See merge request BuildStream/buildstream!1985
Diffstat (limited to 'src/buildstream/_state.py')
-rw-r--r-- | src/buildstream/_state.py | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/src/buildstream/_state.py b/src/buildstream/_state.py index ec4f895fe..6e08c004d 100644 --- a/src/buildstream/_state.py +++ b/src/buildstream/_state.py @@ -112,6 +112,7 @@ class State: self._task_changed_cbs = [] self._task_groups_changed_cbs = [] self._task_failed_cbs = [] + self._task_retry_cbs = [] ##################################### # Frontend-facing notification APIs # @@ -226,6 +227,23 @@ class State: def unregister_task_failed_callback(self, callback): self._task_failed_cbs.remove(callback) + # register_task_retry_callback() + # + # Registers a callback to be notified when a task is to be retried + # + # Args: + # callback (function): The callback to be notified + # + # Callback Args: + # action_name (str): The name of the action, e.g. 'build' + # full_name (str): The full name of the task, distinguishing + # it from other tasks with the same action name + # e.g. an element's name. + # element_job (bool): (optionally) If an element job failed. + # + def register_task_retry_callback(self, callback): + self._task_retry_cbs.append(callback) + ############################################## # Core-facing APIs for driving notifications # ############################################## @@ -336,6 +354,20 @@ class State: for cb in self._task_failed_cbs: cb(action_name, full_name, element) + # retry_task() + # + # Notify all registered callbacks that a task is to be retried. + # + # This is a core-facing API and should not be called from the frontend + # + # Args: + # action_name: The name of the action, e.g. 'build' + # unique_id: The unique id of the plugin instance to look up + # + def retry_task(self, action_name: str, unique_id: str) -> None: + for cb in self._task_retry_cbs: + cb(action_name, unique_id) + # elapsed_time() # # Fetches the current session elapsed time @@ -354,6 +386,20 @@ class State: start_time = self._session_start or time_now return time_now - start_time + # offset_start_time() + # + # Update the 'start' time of the application by a given offset + # + # This allows modifying the time spent building when BuildStream + # gets paused then restarted, to give an accurate view of the real + # time spend building. + # + # Args: + # offset: the offset to add to the start time + # + def offset_start_time(self, offset: datetime.timedelta) -> None: + self._session_start += offset + # _Task # |