H1+M2 review findings: CSV 5000x50 render cap (truncated with note) + stale output sweep; 4 regression tests (H1x3, M2x1); USER_GUIDE truncation docs
Test / Tests (Python 3.12) (push) Canceled after 0s

This commit is contained in:
sirdave73
2026-09-04 06:34:20 -04:00
parent 72b5f2f0dd
commit 7ea2b2baad
4 changed files with 150 additions and 28 deletions
+25
View File
@@ -67,6 +67,7 @@ WORKER_SLOTS = threading.BoundedSemaphore(4)
# Crash leftovers: sweep work dirs / uploads older than these at startup.
STALE_WORK_SECONDS = 6 * 3600
STALE_OUTPUT_SECONDS = 6 * 3600
STALE_UPLOAD_SECONDS = 3600
app = Flask(__name__)
@@ -374,8 +375,32 @@ def _sweep_stale_work_dirs() -> None:
pass
def _sweep_stale_output_files() -> None:
"""Remove OUTPUT_DIR files left by crashed runs older than the 6h window.
Symmetric to _sweep_stale_work_dirs (finding M2: stale output sweep). Only
finished output files are removed (the directory is dedicated to generated
PDFs); files inside the window are left untouched.
"""
now = time.time()
try:
entries = list(OUTPUT_DIR.iterdir())
except OSError:
return
for entry in entries:
if not entry.is_file():
continue
try:
if now - entry.stat().st_mtime > STALE_OUTPUT_SECONDS:
entry.unlink(missing_ok=True)
except OSError:
pass
# Crash leftovers from the previous process start (finding: stale work dirs).
_sweep_stale_work_dirs()
# Stale generated outputs from the previous process start (finding M2).
_sweep_stale_output_files()
# --------------------------------------------------------------------------