fix(db): use RLock instead of Lock

Fixes issues where a db-accessing service wants to call db-accessing methods with locks.
This commit is contained in:
psychedelicious 2023-10-16 11:16:41 +11:00
parent bedb35af8c
commit 388d36b839
6 changed files with 7 additions and 7 deletions

View File

@ -12,7 +12,7 @@ from .board_image_records_base import BoardImageRecordStorageBase
class SqliteBoardImageRecordStorage(BoardImageRecordStorageBase):
_conn: sqlite3.Connection
_cursor: sqlite3.Cursor
_lock: threading.Lock
_lock: threading.RLock
def __init__(self, db: SqliteDatabase) -> None:
super().__init__()

View File

@ -20,7 +20,7 @@ from .board_records_common import (
class SqliteBoardRecordStorage(BoardRecordStorageBase):
_conn: sqlite3.Connection
_cursor: sqlite3.Cursor
_lock: threading.Lock
_lock: threading.RLock
def __init__(self, db: SqliteDatabase) -> None:
super().__init__()

View File

@ -24,7 +24,7 @@ from .image_records_common import (
class SqliteImageRecordStorage(ImageRecordStorageBase):
_conn: sqlite3.Connection
_cursor: sqlite3.Cursor
_lock: threading.Lock
_lock: threading.RLock
def __init__(self, db: SqliteDatabase) -> None:
super().__init__()

View File

@ -17,7 +17,7 @@ class SqliteItemStorage(ItemStorageABC, Generic[T]):
_conn: sqlite3.Connection
_cursor: sqlite3.Cursor
_id_field: str
_lock: threading.Lock
_lock: threading.RLock
def __init__(self, db: SqliteDatabase, table_name: str, id_field: str = "id"):
super().__init__()

View File

@ -37,7 +37,7 @@ class SqliteSessionQueue(SessionQueueBase):
__invoker: Invoker
__conn: sqlite3.Connection
__cursor: sqlite3.Cursor
__lock: threading.Lock
__lock: threading.RLock
def start(self, invoker: Invoker) -> None:
self.__invoker = invoker

View File

@ -9,7 +9,7 @@ sqlite_memory = ":memory:"
class SqliteDatabase:
conn: sqlite3.Connection
lock: threading.Lock
lock: threading.RLock
_logger: Logger
_config: InvokeAIAppConfig
@ -27,7 +27,7 @@ class SqliteDatabase:
self._logger.info(f"Using database at {location}")
self.conn = sqlite3.connect(location, check_same_thread=False)
self.lock = threading.Lock()
self.lock = threading.RLock()
self.conn.row_factory = sqlite3.Row
if self._config.log_sql: