call gc on remove as well

This commit is contained in:
Eugen Ajechiloae 2024-08-15 16:18:41 +03:00
parent d0131d0b58
commit fd8b7604a9
2 changed files with 6 additions and 1 deletions

View File

@ -388,6 +388,8 @@ class ModelRequestProcessor(object):
return False
self._endpoints.pop(endpoint_url, None)
self._remove_registered_input_model(endpoint_url)
self._engine_processor_lookup.pop(endpoint_url, None)
gc.collect()
return True
def add_canary_endpoint(

View File

@ -94,7 +94,10 @@ class BasePreprocessRequest(object):
def __del__(self):
super_ = super(PreprocessDelWrapper, self)
if callable(getattr(super_, "unload", None)):
super_.unload()
try:
super_.unload()
except Exception as ex:
print("Failed unloading model: {}".format(ex))
if callable(getattr(super_, "__del__", None)):
super_.__del__()