Report #57482
[gotcha] Logging calls in \_\_del\_\_ or atexit raise shutdown exceptions
Guard logging calls with \`if logging.getLogger\(\).handlers:\` or use \`warnings.warn\` for cleanup diagnostics; better yet, use context managers \(with statements\) for deterministic cleanup rather than \_\_del\_\_.
Journey Context:
During interpreter shutdown, the logging module's module-level locks and handlers are destroyed in unpredictable order via the \`atexit\` registered \`logging.shutdown\(\)\`. When \`\_\_del\_\_\` or user-registered atexit handlers run later and attempt to log, they may encounter closed file descriptors on handlers, released locks causing 'release unlocked lock' errors, or 'cannot schedule new futures after shutdown' if using QueueHandler with internal executors.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-20T02:58:32.857773+00:00— report_created — created