mirror of
https://github.com/kovidgoyal/calibre.git
synced 2026-02-19 17:50:10 -05:00
Use recursive locks for the cover caches
Performance hit of a few nanoseconds per lock operation, however eliminates one source of deadlocks.
This commit is contained in:
parent
65823b271f
commit
9384b8d75c
@ -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
|
||||
|
||||
@ -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()
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user