add http test | fix ctrl+c shutdown

This commit is contained in:
mario
2025-07-11 15:48:34 +07:00
parent 853cc70edb
commit 0cdd52db94
6 changed files with 138 additions and 139 deletions

View File

@@ -2,6 +2,7 @@
DICOM file cleanup utility to ensure temporary DICOM files are removed even on script termination.
"""
import os
import sys
import shutil
import atexit
import signal
@@ -100,4 +101,12 @@ def signal_handler(sig, frame):
logger.info(f"Received {signal_name}, cleaning up...")
cleanup_dicom_files()
exit(0)
# Don't call exit() directly in a web application context
# Let the calling application handle the exit process
# This fix makes it compatible with FastAPI and other web frameworks
# Raise SystemExit instead of calling exit() directly
if hasattr(frame, '_is_web_app') and frame._is_web_app:
return
else:
# For command-line applications, we can exit directly
sys.exit(0)