Skip to content

armgit / txtai

Public Imported from GitHub
0

💡 All-in-one AI framework for semantic search, LLM orchestration and language model workflows

Update finalizers to check object attributes haven't already been cleared, closes #722

davidmezzetti3204e4a0d68b
diff --git a/src/python/txtai/app/base.py b/src/python/txtai/app/base.py
index 58cf2a01..00040cfb 100644
--- a/src/python/txtai/app/base.py
+++ b/src/python/txtai/app/base.py
@@ -82,7 +82,7 @@ class Application:
Close threadpool when this object is garbage collected.
"""
- if self.pool:
+ if hasattr(self, "pool") and self.pool:
self.pool.close()
self.pool = None
diff --git a/src/python/txtai/graph/rdbms.py b/src/python/txtai/graph/rdbms.py
index 229b7ec9..721db94a 100644
--- a/src/python/txtai/graph/rdbms.py
+++ b/src/python/txtai/graph/rdbms.py
@@ -35,7 +35,7 @@ class RDBMS(NetworkX):
self.database = None
def __del__(self):
- if self.database:
+ if hasattr(self, "database") and self.database:
self.database.close()
def create(self):
diff --git a/src/python/txtai/workflow/execute.py b/src/python/txtai/workflow/execute.py
index 94deb808..eecb7126 100644
--- a/src/python/txtai/workflow/execute.py
+++ b/src/python/txtai/workflow/execute.py
@@ -88,12 +88,12 @@ class Execute:
Closes concurrent processing pools.
"""
- if self.thread:
+ if hasattr(self, "thread") and self.thread:
self.thread.close()
self.thread.join()
self.thread = None
- if self.process:
+ if hasattr(self, "process") and self.process:
self.process.close()
self.process.join()
self.process = None