mirror of
https://github.com/invoke-ai/InvokeAI
synced 2024-08-30 20:32:17 +00:00
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:
parent
bedb35af8c
commit
388d36b839
@ -12,7 +12,7 @@ from .board_image_records_base import BoardImageRecordStorageBase
|
|||||||
class SqliteBoardImageRecordStorage(BoardImageRecordStorageBase):
|
class SqliteBoardImageRecordStorage(BoardImageRecordStorageBase):
|
||||||
_conn: sqlite3.Connection
|
_conn: sqlite3.Connection
|
||||||
_cursor: sqlite3.Cursor
|
_cursor: sqlite3.Cursor
|
||||||
_lock: threading.Lock
|
_lock: threading.RLock
|
||||||
|
|
||||||
def __init__(self, db: SqliteDatabase) -> None:
|
def __init__(self, db: SqliteDatabase) -> None:
|
||||||
super().__init__()
|
super().__init__()
|
||||||
|
@ -20,7 +20,7 @@ from .board_records_common import (
|
|||||||
class SqliteBoardRecordStorage(BoardRecordStorageBase):
|
class SqliteBoardRecordStorage(BoardRecordStorageBase):
|
||||||
_conn: sqlite3.Connection
|
_conn: sqlite3.Connection
|
||||||
_cursor: sqlite3.Cursor
|
_cursor: sqlite3.Cursor
|
||||||
_lock: threading.Lock
|
_lock: threading.RLock
|
||||||
|
|
||||||
def __init__(self, db: SqliteDatabase) -> None:
|
def __init__(self, db: SqliteDatabase) -> None:
|
||||||
super().__init__()
|
super().__init__()
|
||||||
|
@ -24,7 +24,7 @@ from .image_records_common import (
|
|||||||
class SqliteImageRecordStorage(ImageRecordStorageBase):
|
class SqliteImageRecordStorage(ImageRecordStorageBase):
|
||||||
_conn: sqlite3.Connection
|
_conn: sqlite3.Connection
|
||||||
_cursor: sqlite3.Cursor
|
_cursor: sqlite3.Cursor
|
||||||
_lock: threading.Lock
|
_lock: threading.RLock
|
||||||
|
|
||||||
def __init__(self, db: SqliteDatabase) -> None:
|
def __init__(self, db: SqliteDatabase) -> None:
|
||||||
super().__init__()
|
super().__init__()
|
||||||
|
@ -17,7 +17,7 @@ class SqliteItemStorage(ItemStorageABC, Generic[T]):
|
|||||||
_conn: sqlite3.Connection
|
_conn: sqlite3.Connection
|
||||||
_cursor: sqlite3.Cursor
|
_cursor: sqlite3.Cursor
|
||||||
_id_field: str
|
_id_field: str
|
||||||
_lock: threading.Lock
|
_lock: threading.RLock
|
||||||
|
|
||||||
def __init__(self, db: SqliteDatabase, table_name: str, id_field: str = "id"):
|
def __init__(self, db: SqliteDatabase, table_name: str, id_field: str = "id"):
|
||||||
super().__init__()
|
super().__init__()
|
||||||
|
@ -37,7 +37,7 @@ class SqliteSessionQueue(SessionQueueBase):
|
|||||||
__invoker: Invoker
|
__invoker: Invoker
|
||||||
__conn: sqlite3.Connection
|
__conn: sqlite3.Connection
|
||||||
__cursor: sqlite3.Cursor
|
__cursor: sqlite3.Cursor
|
||||||
__lock: threading.Lock
|
__lock: threading.RLock
|
||||||
|
|
||||||
def start(self, invoker: Invoker) -> None:
|
def start(self, invoker: Invoker) -> None:
|
||||||
self.__invoker = invoker
|
self.__invoker = invoker
|
||||||
|
@ -9,7 +9,7 @@ sqlite_memory = ":memory:"
|
|||||||
|
|
||||||
class SqliteDatabase:
|
class SqliteDatabase:
|
||||||
conn: sqlite3.Connection
|
conn: sqlite3.Connection
|
||||||
lock: threading.Lock
|
lock: threading.RLock
|
||||||
_logger: Logger
|
_logger: Logger
|
||||||
_config: InvokeAIAppConfig
|
_config: InvokeAIAppConfig
|
||||||
|
|
||||||
@ -27,7 +27,7 @@ class SqliteDatabase:
|
|||||||
self._logger.info(f"Using database at {location}")
|
self._logger.info(f"Using database at {location}")
|
||||||
|
|
||||||
self.conn = sqlite3.connect(location, check_same_thread=False)
|
self.conn = sqlite3.connect(location, check_same_thread=False)
|
||||||
self.lock = threading.Lock()
|
self.lock = threading.RLock()
|
||||||
self.conn.row_factory = sqlite3.Row
|
self.conn.row_factory = sqlite3.Row
|
||||||
|
|
||||||
if self._config.log_sql:
|
if self._config.log_sql:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user