[Core] add clean up method for diffusion engine (#219)

Signed-off-by: zjy0516 <riverclouds.zhu@qq.com>
This commit is contained in:
Jiangyun Zhu authored and GitHub committed 2025-12-08 03:52:07 +00:00
1 parent 02b1b36c6d
commit aa689e6af0
13 files changed
+309 -10

No files matched your search

+11
View File
@@ -47,3 +47,14 @@ class Omni:
if hasattr(self.instance, "generate"):
return getattr(self.instance, "generate")(*args, **kwargs)
raise AttributeError(f"'{self.instance.__class__.__name__}' has no attribute 'generate'")
def close(self) -> None:
close_method = getattr(self.instance, "close", None)
if callable(close_method):
close_method()
def __del__(self): # pragma: no cover - best effort cleanup
try:
self.close()
except Exception:
pass