diff --git a/src/calibre/db/utils.py b/src/calibre/db/utils.py index 45d9ab637b..c5ba3b74ef 100644 --- a/src/calibre/db/utils.py +++ b/src/calibre/db/utils.py @@ -13,7 +13,7 @@ import tempfile from collections import OrderedDict, namedtuple from contextlib import suppress from locale import localeconv -from threading import Lock +from threading import RLock from calibre import as_unicode, prints from calibre.constants import cache_dir, get_windows_number_formats, iswindows, preferred_encoding @@ -136,7 +136,7 @@ class ThumbnailCache: self.group_id = 'group' self.thumbnail_size = thumbnail_size self.size_changed = False - self.lock = Lock() + self.lock = RLock() self.min_disk_cache = min_disk_cache if test_mode: self.log = self.fail_on_error diff --git a/src/calibre/gui2/library/caches.py b/src/calibre/gui2/library/caches.py index b53f3e8de0..c01f33798a 100644 --- a/src/calibre/gui2/library/caches.py +++ b/src/calibre/gui2/library/caches.py @@ -12,7 +12,7 @@ from collections import OrderedDict from collections.abc import Iterable, Iterator, MutableMapping from functools import partial from queue import Empty, LifoQueue, Queue, ShutDown -from threading import Event, Lock, Thread, current_thread +from threading import Event, RLock, Thread, current_thread from time import monotonic from typing import TypeVar @@ -46,7 +46,7 @@ class RAMCache(MutableMapping[int, T]): def __init__(self, limit=100): self.items = OrderedDict[int, T]() - self.lock = Lock() + self.lock = RLock() self.limit = limit self.pixmap_staging: list[T] = [] self.gui_thread = current_thread()