mirror of
https://github.com/DS4SD/docling.git
synced 2025-12-10 13:48:13 +00:00
chore: Safer unloading of DPv4 backend (#1867)
fix: Safer unloading of DPv4 backend Signed-off-by: Christoph Auer <cau@zurich.ibm.com>
This commit is contained in:
@@ -187,7 +187,17 @@ class DoclingParseV4DocumentBackend(PdfDocumentBackend):
|
||||
|
||||
def unload(self):
|
||||
super().unload()
|
||||
self.dp_doc.unload()
|
||||
with pypdfium2_lock:
|
||||
self._pdoc.close()
|
||||
self._pdoc = None
|
||||
# Unload docling-parse document first
|
||||
if self.dp_doc is not None:
|
||||
self.dp_doc.unload()
|
||||
self.dp_doc = None
|
||||
|
||||
# Then close pypdfium2 document with proper locking
|
||||
if self._pdoc is not None:
|
||||
with pypdfium2_lock:
|
||||
try:
|
||||
self._pdoc.close()
|
||||
except Exception:
|
||||
# Ignore cleanup errors
|
||||
pass
|
||||
self._pdoc = None
|
||||
|
||||
Reference in New Issue
Block a user