Closed lordwelch closed 1 year ago
Because the GUI search is in another thread sqlite3.ProgrammingError: SQLite objects created in a thread can only be used in that same thread. The object was created in thread id 139795925960512 and this is thread id 139792956237504.
Maybe using the mokkari cache is not possible after all?
I presume this was correct (enough)?
def __init__(self, version: str, cache_folder: pathlib.Path):
super().__init__(version, cache_folder)
# Default settings
self.username: str = ""
self.user_password: str = self.api_key
self.mokkari_api = mokkari.api(
self.username,
self.user_password,
cache=mokkari.sqlite_cache.SqliteCache(str(self.cache_folder / "metron_cache.db"), expire=7),
user_agent="comictagger/" + self.version,
)
def parse_settings(self, settings: dict[str, Any]) -> dict[str, Any]:
settings = super().parse_settings(settings)
self.use_series_start_as_volume = settings["met_use_series_start_as_volume"]
self.display_variants = settings["met_display_variants"]
self.find_series_covers = settings["met_series_covers"]
self.use_ongoing_issue_count = settings["met_use_ongoing"]
self.username = settings["met_username"]
self.user_password = settings["metron_key"]
self.mokkari_api = mokkari.api(
self.username,
self.user_password,
cache=mokkari.sqlite_cache.SqliteCache(str(self.cache_folder / "metron_cache.db"), expire=7),
user_agent="comictagger/" + self.version,
)
return settings
Using CT cache doesn't present the problem.
I see this was done in 7469c65. I'll close this issue now
Currently the Mokkari api is instantiated for each request. This probably allows bypassing rate limits and makes every cache lookup take longer (yes the cache builtin to comictagger has the same issue). The api object should be stored on the Talker object. It should be created in
__init__
and inparse_settings
and assigned to egself.metron_api
instead of here