diff --git a/src/calibre/db/listeners.py b/src/calibre/db/listeners.py index 9857b15ae0..33523b2183 100644 --- a/src/calibre/db/listeners.py +++ b/src/calibre/db/listeners.py @@ -42,7 +42,7 @@ class EventType(Enum): book_edited = auto() -class EventDispatcher: +class EventDispatcher(Thread): def __init__(self): Thread.__init__(self, name='DBListener', daemon=True) diff --git a/src/calibre/srv/library_broker.py b/src/calibre/srv/library_broker.py index 948852affe..3fabdb3c41 100644 --- a/src/calibre/srv/library_broker.py +++ b/src/calibre/srv/library_broker.py @@ -15,6 +15,13 @@ from calibre.utils.monotonic import monotonic from polyglot.builtins import iteritems, itervalues +def gui_on_db_event(event_type, library_id, event_data): + from calibre.gui2.ui import get_gui + gui = get_gui() + if gui is not None: + gui.library_broker.on_db_event(event_type, library_id, event_data) + + def canonicalize_path(p): if isinstance(p, bytes): p = p.decode(filesystem_encoding) @@ -222,7 +229,7 @@ class GuiLibraryBroker(LibraryBroker): with self: self.listening_for_db_events = True for db in self.loaded_dbs.values(): - db.new_api.add_listener(self.on_db_event) + db.new_api.add_listener(gui_on_db_event) def on_db_event(self, event_type, library_id, event_data): from calibre.gui2.ui import get_gui