Update api/ltx_server_refactored.py
Browse files- api/ltx_server_refactored.py +0 -19
api/ltx_server_refactored.py
CHANGED
|
@@ -125,25 +125,6 @@ class VideoService:
|
|
| 125 |
def finalize(self, keep_paths=None, extra_paths=None, clear_gpu=True):
|
| 126 |
print("[DEBUG] Finalize: iniciando limpeza...")
|
| 127 |
keep = set(keep_paths or []); extras = set(extra_paths or [])
|
| 128 |
-
removed_files = 0
|
| 129 |
-
for f in list(self._tmp_files | extras):
|
| 130 |
-
try:
|
| 131 |
-
if f not in keep and os.path.isfile(f):
|
| 132 |
-
os.remove(f); removed_files += 1; print(f"[DEBUG] Removido arquivo tmp: {f}")
|
| 133 |
-
except Exception as e:
|
| 134 |
-
print(f"[DEBUG] Falha removendo arquivo {f}: {e}")
|
| 135 |
-
finally:
|
| 136 |
-
self._tmp_files.discard(f)
|
| 137 |
-
removed_dirs = 0
|
| 138 |
-
for d in list(self._tmp_dirs):
|
| 139 |
-
try:
|
| 140 |
-
if d not in keep and os.path.isdir(d):
|
| 141 |
-
shutil.rmtree(d, ignore_errors=True); removed_dirs += 1; print(f"[DEBUG] Removido diret贸rio tmp: {d}")
|
| 142 |
-
except Exception as e:
|
| 143 |
-
print(f"[DEBUG] Falha removendo diret贸rio {d}: {e}")
|
| 144 |
-
finally:
|
| 145 |
-
self._tmp_dirs.discard(d)
|
| 146 |
-
print(f"[DEBUG] Finalize: arquivos removidos={removed_files}, dirs removidos={removed_dirs}")
|
| 147 |
gc.collect()
|
| 148 |
try:
|
| 149 |
if clear_gpu and torch.cuda.is_available():
|
|
|
|
| 125 |
def finalize(self, keep_paths=None, extra_paths=None, clear_gpu=True):
|
| 126 |
print("[DEBUG] Finalize: iniciando limpeza...")
|
| 127 |
keep = set(keep_paths or []); extras = set(extra_paths or [])
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 128 |
gc.collect()
|
| 129 |
try:
|
| 130 |
if clear_gpu and torch.cuda.is_available():
|