Files
mtusi2026lab7/src/state.py
T
ejur22 d995f98446
Skeleton contracts / contracts (pull_request) Canceled after 0s
Lab 7
2026-11-27 20:47:58 +03:00

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()