maple.utils.cleanup.CleanupManager

class maple.utils.cleanup.CleanupManager

Singleton manager for automatic resource cleanup.

Manages cleanup of Docker containers and custom cleanup handlers. Uses signal handlers (SIGINT, SIGTERM) and atexit hooks to ensure resources are properly cleaned up even when the program terminates unexpectedly.

The class implements thread-safe singleton pattern to ensure only one instance exists throughout the application lifecycle.

Methods

__init__()

Initialize the CleanupManager instance.

cleanup_all()

Clean up all registered resources.

instance()

Get the singleton instance of CleanupManager.

register_container(container_id[, name])

Register a Docker container for automatic cleanup.

register_handler(name, handler)

Register a custom cleanup handler function.

unregister_container(container_id)

Unregister a Docker container from automatic cleanup.

unregister_handler(name)

Unregister a custom cleanup handler.

Attributes

active_containers

Get set of currently registered container IDs.