Files
pydicom-migrasi-clarity/api-app/api_cleanup.py
2025-07-11 15:48:34 +07:00

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