diff --git a/src/calibre/gui2/ui.py b/src/calibre/gui2/ui.py index 5a00147b82..824d2fdf22 100644 --- a/src/calibre/gui2/ui.py +++ b/src/calibre/gui2/ui.py @@ -14,7 +14,6 @@ import os import re import sys import textwrap -import time from collections import OrderedDict, deque from io import BytesIO from queue import Empty, Queue @@ -1253,6 +1252,7 @@ class Main(MainWindow, MainWindowMixin, DeviceMixin, EmailMixin, # {{{ self.library_view.connect_to_book_display_timer.stop() self.shutdown_started.emit() self.show_shutdown_message() + timed_print('Shutdown message shown...') self.server_change_notification_timer.stop() self.extra_files_watcher.clear() try: @@ -1266,7 +1266,9 @@ class Main(MainWindow, MainWindowMixin, DeviceMixin, EmailMixin, # {{{ _('Running database shutdown plugins. This could take a few seconds...')) self.grid_view.shutdown() + timed_print('Grid view shutdown') self.bookshelf_view.shutdown() + timed_print('Bookshelf view shutdown') db = None try: db = self.library_view.model().db @@ -1282,6 +1284,7 @@ class Main(MainWindow, MainWindowMixin, DeviceMixin, EmailMixin, # {{{ db.prefs.write_serialized(prefs['library_path']) for action in self.iactions.values(): action.shutting_down() + timed_print('Actions shutdown') if write_settings: self.write_settings() if getattr(self, 'update_checker', None): @@ -1291,6 +1294,7 @@ class Main(MainWindow, MainWindowMixin, DeviceMixin, EmailMixin, # {{{ self.job_manager.threaded_server.close() self.device_manager.keep_going = False self.auto_adder.stop() + timed_print('Various services shutdown') # Do not report any errors that happen after the shutdown # We cannot restore the original excepthook as that causes PyQt to # call abort() on unhandled exceptions @@ -1306,8 +1310,10 @@ class Main(MainWindow, MainWindowMixin, DeviceMixin, EmailMixin, # {{{ mb = self.library_view.model().metadata_backup if mb is not None: mb.stop() + timed_print('Metadata backup shutdown') self.library_view.model().close() + timed_print('Current database closed') try: if self.content_server is not None: @@ -1319,18 +1325,20 @@ class Main(MainWindow, MainWindowMixin, DeviceMixin, EmailMixin, # {{{ s = self.content_server self.content_server = None s.exit() + timed_print('Content server shutdown') except KeyboardInterrupt: pass except Exception: pass self.hide_windows() + timed_print('Windows hidden') if self._spare_pool is not None: self._spare_pool.shutdown() from calibre.scraper.simple import cleanup_overseers wait_for_cleanup = cleanup_overseers() from calibre.live import async_stop_worker wait_for_stop = async_stop_worker() - time.sleep(2) + timed_print('Waiting for overseers and live to shutdown') self.istores.join() wait_for_cleanup() wait_for_stop()