Report #12982
[gotcha] Log records lost on exit because logging shutdown happens before daemon threads flush or non-daemon threads block exit
Ensure all logging handlers are explicitly flushed via logging.shutdown\(\) in your exit handler, or use non-daemon threads with timeouts for queue listeners; never rely on atexit alone for critical logs.
Journey Context:
The logging module registers shutdown\(\) with atexit to flush buffers. If you use QueueHandler with a listener in a daemon thread, the main thread exits, atexit runs, but the daemon thread may be killed before processing remaining items. If you use non-daemon threads, they block exit forever. The solution is manual shutdown\(\) calls before exit, or using the concurrent.futures pattern with wait timeouts, or ensuring critical logs use blocking handlers.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T17:25:06.663179+00:00— report_created — created