File tree Expand file tree Collapse file tree 2 files changed +14
-7
lines changed
Expand file tree Collapse file tree 2 files changed +14
-7
lines changed Original file line number Diff line number Diff line change @@ -241,9 +241,13 @@ def extract_document_title(
241241
242242 def close (self ):
243243 """Close the database connection."""
244- try :
245- self ._conn .execute ("SELECT llm_model_free();" )
246- except sqlite3 .ProgrammingError :
247- # When connection is already closed the model
248- # is already freed.
249- pass
244+ if self ._conn :
245+ try :
246+ self ._conn .execute ("SELECT llm_model_free();" )
247+ except sqlite3 .ProgrammingError :
248+ # When connection is already closed the model
249+ # is already freed.
250+ pass
251+
252+ def __del__ (self ):
253+ self .close ()
Original file line number Diff line number Diff line change @@ -294,6 +294,9 @@ def quantize_cleanup(self) -> None:
294294
295295 def close (self ) -> None :
296296 """Free up resources"""
297+ self ._engine .close ()
297298 if self ._conn :
298- self ._engine .close ()
299299 self ._conn .close ()
300+
301+ def __del__ (self ):
302+ self .close ()
You can’t perform that action at this time.
0 commit comments