summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJürg Billeter <j@bitron.ch>2018-02-27 07:39:32 +0100
committerTristan Van Berkom <tristan.van.berkom@gmail.com>2018-02-27 11:43:18 +0000
commita8a942b79b9b1373ef2750e37d1b20cd336b5d6d (patch)
tree3f727e0e30fbd7e595415755b60dcd7f01f3d748
parent14c81d99ca3bcff3b7daf24500e061cc65ed7f9d (diff)
downloadbuildstream-a8a942b79b9b1373ef2750e37d1b20cd336b5d6d.tar.gz
element.py: Add _can_query_cache() method
Keep the knowledge about which cache key is required for cache queries within the Element class.
-rw-r--r--buildstream/_scheduler/fetchqueue.py3
-rw-r--r--buildstream/_scheduler/pullqueue.py3
-rw-r--r--buildstream/element.py11
3 files changed, 13 insertions, 4 deletions
diff --git a/buildstream/_scheduler/fetchqueue.py b/buildstream/_scheduler/fetchqueue.py
index 6f4af018c..a99c3c9d7 100644
--- a/buildstream/_scheduler/fetchqueue.py
+++ b/buildstream/_scheduler/fetchqueue.py
@@ -49,8 +49,7 @@ class FetchQueue(Queue):
# Optionally skip elements that are already in the artifact cache
if self.skip_cached:
- # cache cannot be queried until strict cache key is available
- if element._get_strict_cache_key() is None:
+ if not element._can_query_cache():
return QueueStatus.WAIT
if element._cached():
diff --git a/buildstream/_scheduler/pullqueue.py b/buildstream/_scheduler/pullqueue.py
index 458c65e92..3413d2783 100644
--- a/buildstream/_scheduler/pullqueue.py
+++ b/buildstream/_scheduler/pullqueue.py
@@ -39,8 +39,7 @@ class PullQueue(Queue):
# state of dependencies may have changed, recalculate element state
element._update_state()
- # cache cannot be queried until strict cache key is available
- if element._get_strict_cache_key() is None:
+ if not element._can_query_cache():
return QueueStatus.WAIT
if element._pull_pending():
diff --git a/buildstream/element.py b/buildstream/element.py
index c1f69947e..9bed99dc1 100644
--- a/buildstream/element.py
+++ b/buildstream/element.py
@@ -958,6 +958,17 @@ class Element(Plugin):
def _get_strict_cache_key(self):
return self.__strict_cache_key
+ # _can_query_cache():
+ #
+ # Returns whether the cache key required for cache queries is available.
+ #
+ # Returns:
+ # (bool): True if cache can be queried
+ #
+ def _can_query_cache(self):
+ # cache cannot be queried until strict cache key is available
+ return self.__strict_cache_key is not None
+
# _get_full_display_key():
#
# Returns cache keys for display purposes