Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions src/acme_sdk/utils/batching.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,3 +99,13 @@ def shutdown(self, timeout: float | None = None) -> None:
if timeout is None:
timeout = self._flush_interval * 3
self._thread.join(timeout=timeout)


def _ensure_flush_on_shutdown(processor: BatchProcessor) -> None:
"""Ensure final flush happens before interpreter exit.

This is registered as an atexit handler and ensures that the
background flush thread completes before the interpreter exits.
"""
if not processor._shutdown:
processor.shutdown(timeout=processor._flush_interval * 3)