summaryrefslogtreecommitdiff
path: root/src/buildstream/_state.py
diff options
context:
space:
mode:
authorTristan van Berkom <tristan@codethink.co.uk>2020-12-10 15:25:12 +0900
committerTristan van Berkom <tristan@codethink.co.uk>2020-12-10 18:12:37 +0900
commitcbc8e78fed4caa6b0f2b6590d7d4025c46c0e500 (patch)
tree30f8f3064c8b186c3db932978d80e16eabb72b0e /src/buildstream/_state.py
parentf9ac4815ebec826aa076bff5ffd45f7559a752c9 (diff)
downloadbuildstream-cbc8e78fed4caa6b0f2b6590d7d4025c46c0e500.tar.gz
Refactor: Use explicit invocation for retrying jobs.
We created the State object in the core for the purpose of advertizing state to the frontend, and the frontend can register callbacks and get updates to state changes (implicit invocation in the frontend), state always belongs to the core and the frontend can only read state. When the frontend asks the core to do something, this should always be done with an explicit function call, and preferably not via the State object, as this confuses the use of state, which is only a readonly state advertizing desk. This was broken (implemented backwards) for job retries, instead we had the frontend telling state "It has been requested that this job be retried !", and then we had the core registering callbacks to that frontend request - this direction of implicit invocation should not happen (the core should never have to register callbacks on the State object at all in fact). Summary of changes: * _stream.py: Change _failure_retry(), which was for some reason private albeit called from the frontend, to an explicit function call named "retry_job()". Instead of calling into the State object and causing core-side callbacks to be triggered, later to be handled by the Scheduler, implement the retry directly from the Stream, since this implementation deals only with Queues and State, which already directly belong to the Stream object, there is no reason to trouble the Scheduler with this. * _scheduler.py: Remove the callback handling the State "task retry" event. * _state.py: Remove the task retry callback chain completely. * _frontend/app.py: Call stream.retry_job() instead of stream.failure_retry(), now passing along the task's action name rather than the task's ID. This API now assumes that Stream.retry_job() can only be called on a task which originates from a scheduler Queue, and expects to be given the action name of the queue in which the given element has failed and should be retried..
Diffstat (limited to 'src/buildstream/_state.py')
-rw-r--r--src/buildstream/_state.py29
1 files changed, 0 insertions, 29 deletions
diff --git a/src/buildstream/_state.py b/src/buildstream/_state.py
index 0233dd323..773aa2146 100644
--- a/src/buildstream/_state.py
+++ b/src/buildstream/_state.py
@@ -112,7 +112,6 @@ class State:
self._task_changed_cbs = []
self._task_groups_changed_cbs = []
self._task_failed_cbs = []
- self._task_retry_cbs = []
#####################################
# Frontend-facing notification APIs #
@@ -216,20 +215,6 @@ 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:
- # task_id (str): The unique identifier of the task
- # unique_id: The unique id of the plugin instance to look up
- #
- def register_task_retry_callback(self, callback):
- self._task_retry_cbs.append(callback)
-
##############################################
# Core-facing APIs for driving notifications #
##############################################
@@ -334,20 +319,6 @@ class State:
for cb in self._task_failed_cbs:
cb(task_id, 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:
- # task_id (str): The unique identifier of the task
- # unique_id: The unique id of the plugin instance to look up
- #
- def retry_task(self, task_id: str, unique_id: str) -> None:
- for cb in self._task_retry_cbs:
- cb(task_id, unique_id)
-
# elapsed_time()
#
# Fetches the current session elapsed time