Merge pull request #4254 from ostcar/fix_partial_cache

Make sure the cache is ensured before manipulating it
This commit is contained in:
Jochen Saalfeld 2019-02-05 08:08:19 +01:00 committed by GitHub
commit a64d436884
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -133,6 +133,11 @@ class ElementCache:
Returns the new generated change_id.
"""
if not self.ensured:
raise RuntimeError(
"Call element_cache.ensure_cache before changing elements."
)
deleted_elements = []
changed_elements = []
for element_id, data in elements.items():
@ -265,6 +270,11 @@ class ElementCache:
# If the restricted_data_cache is not used, there is nothing to do
return
if not self.ensured:
raise RuntimeError(
"Call element_cache.ensure_cache before updating restricted data."
)
# Try to write a special key.
# If this succeeds, there is noone else currently updating the cache.
# TODO: Make a timeout. Else this could block forever