mirror of
https://github.com/Kozea/Radicale.git
synced 2025-06-26 16:45:52 +00:00
Don't read cache entry twice with exclusive access
This commit is contained in:
parent
1576f9b7fb
commit
ed3708db22
1 changed files with 9 additions and 11 deletions
|
@ -1299,17 +1299,15 @@ class Collection(BaseCollection):
|
||||||
href)
|
href)
|
||||||
vobject_item = None
|
vobject_item = None
|
||||||
if input_hash != cache_hash:
|
if input_hash != cache_hash:
|
||||||
# Lock the item cache to prevent multpile processes from generating
|
with contextlib.ExitStack() as lock_stack:
|
||||||
# the same data in parallel. This is only needed for performance.
|
# Lock the item cache to prevent multpile processes from
|
||||||
if self._lock.locked() == "w":
|
# generating the same data in parallel.
|
||||||
# The access is already exclusive, use dummy context manager.
|
# This improves the performance for multiple requests.
|
||||||
lock = contextlib.suppress()
|
if self._lock.locked() == "r":
|
||||||
else:
|
lock_stack.enter_context(self._acquire_cache_lock("item"))
|
||||||
lock = self._acquire_cache_lock("item")
|
# Check if another process created the file in the meantime
|
||||||
with lock:
|
cache_hash, uid, etag, text, tag, start, end = \
|
||||||
# Check if another process created the file in the meantime.
|
self._load_item_cache(href)
|
||||||
cache_hash, uid, etag, text, tag, start, end = \
|
|
||||||
self._load_item_cache(href)
|
|
||||||
if input_hash != cache_hash:
|
if input_hash != cache_hash:
|
||||||
try:
|
try:
|
||||||
vobject_items = tuple(vobject.readComponents(
|
vobject_items = tuple(vobject.readComponents(
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue