From 7f6f53149d3d83a967edc20c770e37e5db96d2a7 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Sat, 6 Aug 2022 09:42:36 +0530 Subject: [PATCH] Ignore importerror during interpreter shutdown while closing db --- src/calibre/db/cache.py | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/src/calibre/db/cache.py b/src/calibre/db/cache.py index 0f9c332eda..839854e672 100644 --- a/src/calibre/db/cache.py +++ b/src/calibre/db/cache.py @@ -2461,13 +2461,17 @@ class Cache: self.shutting_down = True self.event_dispatcher.close() self._shutdown_fts() - from calibre.customize.ui import available_library_closed_plugins - for plugin in available_library_closed_plugins(): - try: - plugin.run(self) - except Exception: - import traceback - traceback.print_exc() + try: + from calibre.customize.ui import available_library_closed_plugins + except ImportError: + pass # happens during interpreter shutdown + else: + for plugin in available_library_closed_plugins(): + try: + plugin.run(self) + except Exception: + import traceback + traceback.print_exc() self._shutdown_fts(stage=2) with self.write_lock: self.backend.close()