X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/1913b4edcb176909e8cf7ef3272c41bf8f2c7e1a..5a46895af3657b549264a68bd2450baf8dbf7215:/sdk/python/arvados/keep.py diff --git a/sdk/python/arvados/keep.py b/sdk/python/arvados/keep.py index ce4c6f81f6..44f10e4fb9 100644 --- a/sdk/python/arvados/keep.py +++ b/sdk/python/arvados/keep.py @@ -336,11 +336,18 @@ class KeepBlockCache(object): except Exception as e: tryagain = True + # Check if we should evict things from the cache. Either + # because we added a new thing or we adjusted the limits down, + # so we might need to push something out. + self.cap_cache() + + if not tryagain: + # Done + return + try: - if tryagain: - # There was an error. Evict some slots and try again. - self.cap_cache() - slot.set(blob) + # There was an error, we ran cap_cache so try one more time. + slot.set(blob) except Exception as e: # It failed again. Give up. raise arvados.errors.KeepCacheError("Unable to save block %s to disk cache: %s" % (slot.locator, e)) @@ -349,7 +356,6 @@ class KeepBlockCache(object): # slot one way or another. slot.ready.set() - self.cap_cache() class Counter(object): def __init__(self, v=0):