Ensure deleted cache objects are closed

Also ensure close is only called once
This commit is contained in:
Kovid Goyal 2022-04-27 19:34:39 +05:30
parent be83f8bfa6
commit f65a05cc8f
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -2355,8 +2355,14 @@ class Cache:
def vacuum(self): def vacuum(self):
self.backend.vacuum() self.backend.vacuum()
def __del__(self):
self.close()
@write_api @write_api
def close(self): def close(self):
if hasattr(self, 'close_called'):
return
self.close_called = True
self.shutting_down = True self.shutting_down = True
self.event_dispatcher.close() self.event_dispatcher.close()
if self.fts_queue_thread is not None: if self.fts_queue_thread is not None: