mirror of
https://github.com/comfyanonymous/ComfyUI.git
synced 2026-01-08 21:30:50 +08:00
Fix AttributeError in ModelPatcher.__del__ by adding safety check for 'pinned'
This commit is contained in:
parent
532e285079
commit
a64fe846af
@ -651,8 +651,12 @@ class ModelPatcher:
|
|||||||
self.pinned.remove(key)
|
self.pinned.remove(key)
|
||||||
|
|
||||||
def unpin_all_weights(self):
|
def unpin_all_weights(self):
|
||||||
for key in list(self.pinned):
|
if hasattr(self, 'pinned'): # Safety check
|
||||||
self.unpin_weight(key)
|
for key in list(self.pinned):
|
||||||
|
self.unpin_weight(key)
|
||||||
|
else:
|
||||||
|
# Log or skip: self.pinned was not set
|
||||||
|
pass
|
||||||
|
|
||||||
def _load_list(self):
|
def _load_list(self):
|
||||||
loading = []
|
loading = []
|
||||||
@ -1354,6 +1358,12 @@ class ModelPatcher:
|
|||||||
self.clear_cached_hook_weights()
|
self.clear_cached_hook_weights()
|
||||||
|
|
||||||
def __del__(self):
|
def __del__(self):
|
||||||
self.unpin_all_weights()
|
try:
|
||||||
self.detach(unpatch_all=False)
|
if hasattr(self, 'pinned'):
|
||||||
|
self.unpin_all_weights()
|
||||||
|
# Existing code...
|
||||||
|
except Exception as e:
|
||||||
|
# Suppress errors in destructor to avoid noise
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user