summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTristan Maat <tristan.maat@codethink.co.uk>2019-10-23 16:23:25 +0100
committerTristan Maat <tristan.maat@codethink.co.uk>2019-11-04 11:26:48 +0000
commit164a07516dc4406ad837a704a55cd892cfa74f4f (patch)
tree0c361e7f54980cdc4661bd028645663cb25e64d3
parent3c2d1fe978cb99d0c414ba25ecf4c8ff335e3b3d (diff)
downloadbuildstream-tlater/annihilate_update_state.tar.gz
element.py: Refactor __update_ready_for_runtime()tlater/annihilate_update_state
Just as with the previous commit, inspired by our code quality linter. Poor practice from the previous function probably snuck in here too.
-rw-r--r--src/buildstream/element.py48
1 files changed, 28 insertions, 20 deletions
diff --git a/src/buildstream/element.py b/src/buildstream/element.py
index 81a726200..09f8b7a9f 100644
--- a/src/buildstream/element.py
+++ b/src/buildstream/element.py
@@ -3311,31 +3311,39 @@ class Element(Plugin):
# decrementing the appropriate counters.
#
def __update_ready_for_runtime(self):
- if not self.__ready_for_runtime:
- if self.__runtime_deps_without_cache_key == 0 and \
- self.__cache_key is not None:
- self.__ready_for_runtime = True
+ if any((
+ # We're already ready for runtime; no update required
+ self.__ready_for_runtime,
+ # If not all our dependencies are ready yet, we can't be ready
+ # either.
+ not self.__runtime_deps_without_cache_key == 0,
+ # If we're not cached, we can't be ready.
+ self.__cache_key is None,
+ )):
+ return
- # Notify reverse dependencies
- for rdep in self.__reverse_runtime_deps:
- rdep.__runtime_deps_without_cache_key -= 1
- assert not rdep.__runtime_deps_without_cache_key < 0
+ self.__ready_for_runtime = True
+
+ # Notify reverse dependencies
+ for rdep in self.__reverse_runtime_deps:
+ rdep.__runtime_deps_without_cache_key -= 1
+ assert not rdep.__runtime_deps_without_cache_key < 0
- # If all of our runtimes have cache keys, we can calculate ours
- if rdep.__runtime_deps_without_cache_key == 0:
- rdep.__update_ready_for_runtime()
+ # If all of our runtimes have cache keys, we can calculate ours
+ if rdep.__runtime_deps_without_cache_key == 0:
+ rdep.__update_ready_for_runtime()
- for rdep in self.__reverse_build_deps:
- rdep.__build_deps_without_cache_key -= 1
- assert not rdep.__build_deps_without_cache_key < 0
+ for rdep in self.__reverse_build_deps:
+ rdep.__build_deps_without_cache_key -= 1
+ assert not rdep.__build_deps_without_cache_key < 0
- if rdep.__build_deps_without_cache_key == 0:
- rdep.__update_cache_keys()
+ if rdep.__build_deps_without_cache_key == 0:
+ rdep.__update_cache_keys()
- # If the element is cached, and has all of its runtime dependencies cached,
- # now that we have the cache key, we are able to notify reverse dependencies
- # that the element it ready. This is a likely trigger for workspaced elements.
- self._update_ready_for_runtime_and_cached()
+ # If the element is cached, and has all of its runtime dependencies cached,
+ # now that we have the cache key, we are able to notify reverse dependencies
+ # that the element it ready. This is a likely trigger for workspaced elements.
+ self._update_ready_for_runtime_and_cached()
def _overlap_error_detail(f, forbidden_overlap_elements, elements):