@@ -0,0 +1,19 @@
|
||||
"""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()
|
||||
Reference in New Issue
Block a user