20 lines
463 B
Python
20 lines
463 B
Python
"""Process-wide lifecycle flags.
|
|
|
|
``shutting_down`` is raised from the SIGTERM/SIGINT handler before Uvicorn
|
|
stops accepting connections, so ``/health/ready`` reports ``503`` and the
|
|
balancer drains this replica instead of sending it new work.
|
|
"""
|
|
from __future__ import annotations
|
|
|
|
import threading
|
|
|
|
_shutting_down = threading.Event()
|
|
|
|
|
|
def begin_shutdown() -> None:
|
|
_shutting_down.set()
|
|
|
|
|
|
def is_shutting_down() -> bool:
|
|
return _shutting_down.is_set()
|