mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Parallelize db shutdown a bit more
This commit is contained in:
parent
74b218a72a
commit
7f503018ba
@ -980,6 +980,10 @@ class DB:
|
||||
def shutdown_fts(self):
|
||||
if self.fts_enabled:
|
||||
self.fts.shutdown()
|
||||
|
||||
def join_fts(self):
|
||||
if self.fts:
|
||||
self.fts.pool.join()
|
||||
self.fts = None
|
||||
|
||||
def get_connection(self):
|
||||
|
@ -2387,6 +2387,7 @@ class Cache:
|
||||
self.close_called = True
|
||||
self.shutting_down = True
|
||||
self.event_dispatcher.close()
|
||||
self.backend.shutdown_fts()
|
||||
if self.fts_queue_thread is not None:
|
||||
self.fts_job_queue.put(None)
|
||||
from calibre.customize.ui import available_library_closed_plugins
|
||||
@ -2398,10 +2399,10 @@ class Cache:
|
||||
traceback.print_exc()
|
||||
# the fts supervisor thread could be in the middle of committing a
|
||||
# result to the db, so holding a lock here will cause a deadlock
|
||||
self.backend.shutdown_fts()
|
||||
if self.fts_queue_thread is not None:
|
||||
self.fts_queue_thread.join()
|
||||
self.fts_queue_thread = None
|
||||
self.backend.join_fts()
|
||||
with self.write_lock:
|
||||
self.backend.close()
|
||||
|
||||
|
@ -210,11 +210,13 @@ class Pool:
|
||||
w.keep_going = False
|
||||
for i in range(2*len(self.workers)):
|
||||
self.jobs_queue.put(quit)
|
||||
self.supervisor_thread.join()
|
||||
for w in self.workers:
|
||||
w.join()
|
||||
self.workers = []
|
||||
self.initialized.clear()
|
||||
|
||||
def join(self):
|
||||
self.supervisor_thread.join()
|
||||
for w in self.workers:
|
||||
w.join()
|
||||
self.workers = []
|
||||
# }}}
|
||||
|
||||
def do_check_for_work(self):
|
||||
|
Loading…
x
Reference in New Issue
Block a user