add http test | fix ctrl+c shutdown
This commit is contained in:
@@ -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)
|
||||
Reference in New Issue
Block a user