Private
Public Access
0
0

fix(log_pruner): shorter retry loop, smaller sleep to avoid blocking startup

This commit is contained in:
2026-06-05 12:26:58 -04:00
parent 970f198ca6
commit ac08ee875c
+11 -8
View File
@@ -100,21 +100,24 @@ class LogPruner:
try:
sys.stderr.write(f"[LogPruner] Removing {session_id} at {resolved_path} (Size: {total_size} bytes)\n")
# Windows specific: sometimes files are locked.
# We try a few times with small delays.
# Windows specific: sometimes files are locked by the running GUI process.
# We try a few times with backoff so transient locks are retried but
# the main thread (e.g. hook server startup) is not blocked.
def remove_readonly(func, path, excinfo):
os.chmod(path, 0o777)
func(path)
for attempt in range(3):
last_err = None
for attempt in range(2):
try:
shutil.rmtree(resolved_path, onerror=remove_readonly)
last_err = None
break
except OSError:
if attempt < 2:
time.sleep(0.1)
else:
raise
except OSError as e:
last_err = e
time.sleep(0.05)
if last_err is not None:
raise last_err
# Also remove from registry to keep it in sync
if session_id in self.log_registry.data: