diff --git a/core/__init__.py b/core/__init__.py index b232b5c2..ac442dbe 100644 --- a/core/__init__.py +++ b/core/__init__.py @@ -14,7 +14,7 @@ except: from . import filetools from platformcode import config from collections import defaultdict -from lib.sqlitedict import SqliteDict +from lib.sqlitedict import SqliteDict, SqliteMultithread class nested_dict_sqlite(defaultdict): @@ -25,10 +25,12 @@ class nested_dict_sqlite(defaultdict): return value def close(self): - for key in self.keys(): - self[key].close() + sqliteTH.close() + # for key in self.keys(): + # self[key].close() self.clear() db_name = filetools.join(config.get_data_path(), "db.sqlite") -db = nested_dict_sqlite(lambda table: SqliteDict(db_name, table, 'c', True)) +sqliteTH = SqliteMultithread(db_name, autocommit=True, journal_mode="DELETE", timeout=5) +db = nested_dict_sqlite(lambda table: SqliteDict(db_name, table, 'c', True, conn=sqliteTH)) diff --git a/lib/sqlitedict.py b/lib/sqlitedict.py index 93884a4e..6beb08e2 100644 --- a/lib/sqlitedict.py +++ b/lib/sqlitedict.py @@ -109,7 +109,7 @@ class SqliteDict(DictClass): VALID_FLAGS = ['c', 'r', 'w', 'n'] def __init__(self, filename=None, tablename='unnamed', flag='c', - autocommit=False, journal_mode="DELETE", encode=encode, decode=decode, timeout=5): + autocommit=False, journal_mode="DELETE", encode=encode, decode=decode, timeout=5, conn=None): """ Initialize a thread-safe sqlite-backed dictionary. The dictionary will be a table `tablename` in database file `filename`. A single file (=database) @@ -174,7 +174,7 @@ class SqliteDict(DictClass): self.timeout = timeout logger.info("opening Sqlite table %r in %r" % (tablename, filename)) - self.conn = self._new_conn() + self.conn = self._new_conn() if not conn else conn if self.flag == 'r': if self.tablename not in SqliteDict.get_tablenames(self.filename): msg = 'Refusing to create a new table "%s" in read-only DB mode' % tablename @@ -593,7 +593,7 @@ class SqliteMultithread(Thread): while time.time() - start_time < self.timeout: if self._sqlitedict_thread_initialized or self.exception: return - time.sleep(0.1) + time.sleep(0.01) raise TimeoutError("SqliteMultithread failed to flag initialization withing %0.0f seconds." % self.timeout) diff --git a/platformcode/launcher.py b/platformcode/launcher.py index 6e41f12a..da9379cc 100644 --- a/platformcode/launcher.py +++ b/platformcode/launcher.py @@ -35,9 +35,6 @@ def start(): def run(item=None): logger.debug() - # for saving viewmode for precedent menu - platformtools.viewmodeMonitor() - if not item: # Extract item from sys.argv if sys.argv[2]: diff --git a/service.py b/service.py index cf225499..4ad50208 100644 --- a/service.py +++ b/service.py @@ -89,21 +89,18 @@ def update(path, p_dialog, i, t, serie, overwrite): # serie.infoLabels['playcount'] = serie.playcount insertados_total += insertados - except Exception as ex: + except: + import traceback logger.error("Error when saving the chapters of the series") - template = "An exception of type %s occured. Arguments:\n%r" - message = template % (type(ex).__name__, ex.args) - logger.error(message) + logger.error(traceback.format_exc()) - except Exception as ex: + except: + import traceback logger.error("Error in obtaining the episodes of: %s" % serie.show) - template = "An exception of type %s occured. Arguments:\n%r" - message = template % (type(ex).__name__, ex.args) - logger.error(message) + logger.error(traceback.format_exc()) else: logger.debug("Channel %s not active is not updated" % serie.channel) - # Synchronize the episodes seen from the Kodi video library with that of KoD try: if config.is_xbmc(): # If it's Kodi, we do it @@ -127,7 +124,7 @@ def check_for_update(overwrite=True): if config.get_setting("update", "videolibrary") != 0 or overwrite: config.set_setting("updatelibrary_last_check", hoy.strftime('%Y-%m-%d'), "videolibrary") - heading = config.get_localized_string(60389) + heading = config.get_localized_string(60601) p_dialog = platformtools.dialog_progress_bg(config.get_localized_string(20000), heading) p_dialog.update(0, '') show_list = []