summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJürg Billeter <j@bitron.ch>2018-01-23 12:16:08 +0000
committerJürg Billeter <j@bitron.ch>2018-01-23 12:16:08 +0000
commit750a21ef19030da31ba7f336ef55cbe7132d6fbf (patch)
tree381a481c69d944ffed1e03e8ebda948bf589af48
parentbd33627405ffb75a3a4532d75ef4eb678798ce7f (diff)
downloadbuildstream-750a21ef19030da31ba7f336ef55cbe7132d6fbf.tar.gz
Add Element._pull_pending() method
This moves the pull status logic from PullQueue to Element. As PullQueue.process() simply calls Element._pull(), it doesn't make sense to keep the status logic in PullQueue. This is also required to use the pull status in other places without code duplication.
-rw-r--r--buildstream/_scheduler/pullqueue.py11
-rw-r--r--buildstream/element.py18
2 files changed, 19 insertions, 10 deletions
diff --git a/buildstream/_scheduler/pullqueue.py b/buildstream/_scheduler/pullqueue.py
index 38de9cf09..e879b4689 100644
--- a/buildstream/_scheduler/pullqueue.py
+++ b/buildstream/_scheduler/pullqueue.py
@@ -46,18 +46,9 @@ class PullQueue(Queue):
if element._get_strict_cache_key() is None:
return QueueStatus.WAIT
- if element._cached(strength=_KeyStrength.STRONG):
- return QueueStatus.SKIP
- elif element._remotely_cached(strength=_KeyStrength.STRONG):
- # pull artifact using strong key
- return QueueStatus.READY
- elif element._cached():
- return QueueStatus.SKIP
- elif element._remotely_cached():
- # pull artifact using weak key
+ if element._pull_pending():
return QueueStatus.READY
else:
- # nothing to pull
return QueueStatus.SKIP
def done(self, element, result, returncode):
diff --git a/buildstream/element.py b/buildstream/element.py
index 138096caf..ab6713861 100644
--- a/buildstream/element.py
+++ b/buildstream/element.py
@@ -1362,6 +1362,24 @@ class Element(Plugin):
context = self._get_context()
return context._get_strict(project.name)
+ # _pull_pending()
+ #
+ # Check whether the artifact will be pulled.
+ #
+ # Returns:
+ # (bool): Whether a pull operation is pending
+ #
+ def _pull_pending(self):
+ if not self.__strong_cached and self.__remotely_strong_cached:
+ # Pull pending using strict cache key
+ return True
+ elif not self.__cached and self.__remotely_cached:
+ # Pull pending using weak cache key
+ return True
+ else:
+ # No pull pending
+ return False
+
# _update_state()
#
# Keep track of element state. Calculate cache keys if possible and