()
| 50 | |
| 51 | |
| 52 | def create_flush_callback(): |
| 53 | def flush_and_shutdown_callback() -> None: |
| 54 | """ |
| 55 | TODO(dev): add cleanup + flush-to-disk logic here. |
| 56 | """ |
| 57 | return |
| 58 | |
| 59 | flush_ran = False |
| 60 | |
| 61 | def _run_flush(reason: str) -> None: |
| 62 | nonlocal flush_ran |
| 63 | if flush_ran: |
| 64 | return |
| 65 | flush_ran = True |
| 66 | try: |
| 67 | flush_and_shutdown_callback() |
| 68 | except Exception as e: |
| 69 | PrintStyle.warning(f"Shutdown flush failed ({reason}): {e}") |
| 70 | |
| 71 | return _run_flush |
| 72 | |
| 73 | |
| 74 | @extension.extensible |