26 lines
787 B
Python
26 lines
787 B
Python
"""
|
|
Custom cleanup utilities for the API application.
|
|
This module provides customized cleanup functions that are more compatible with FastAPI.
|
|
"""
|
|
import os
|
|
import sys
|
|
import shutil
|
|
import atexit
|
|
from config import settings
|
|
from utils.logger import setup_logger
|
|
from utils.cleanup import _cleanup_dirs, cleanup_dicom_files
|
|
|
|
# Create API cleanup logger
|
|
cleanup_logger = setup_logger("api_cleanup", "logs/api_cleanup.log")
|
|
|
|
def register_api_cleanup():
|
|
"""
|
|
Register cleanup handlers for the API application.
|
|
This avoids registering signal handlers which can conflict with FastAPI.
|
|
"""
|
|
# Only register the atexit handler, not signal handlers
|
|
atexit.register(cleanup_dicom_files)
|
|
cleanup_logger.info("Registered API cleanup handler for exit")
|
|
|
|
return True
|