fed8b2eed7
Backend release / release (push) Waiting to run
Bandit Security Scan / bandit_scan (push) Waiting to run
Build and push multi-arch DocsGPT Docker image / build (linux/amd64, ubuntu-latest, amd64) (push) Waiting to run
Build and push multi-arch DocsGPT Docker image / build (linux/arm64, ubuntu-24.04-arm, arm64) (push) Waiting to run
Build and push multi-arch DocsGPT Docker image / manifest (push) Blocked by required conditions
Build and push DocsGPT FE Docker image for development / build (linux/amd64, ubuntu-latest, amd64) (push) Waiting to run
Build and push DocsGPT FE Docker image for development / build (linux/arm64, ubuntu-24.04-arm, arm64) (push) Waiting to run
Build and push DocsGPT FE Docker image for development / manifest (push) Blocked by required conditions
Python linting / ruff (push) Waiting to run
Run python tests with pytest / Run tests and count coverage (3.12) (push) Waiting to run
React Widget Build / build (push) Waiting to run
29 lines
849 B
Python
29 lines
849 B
Python
"""Process-wide graceful-shutdown flag.
|
|
|
|
Raised by ``BoundedDrainUvicornWorker`` when a drain starts and polled by the
|
|
SSE/long-poll generators (which run in a2wsgi threads asyncio can't cancel) so
|
|
they return promptly instead of hanging the worker until the ``--timeout``
|
|
watchdog kills it. Standalone module so the worker can import it without the app.
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
import threading
|
|
|
|
_shutting_down = threading.Event()
|
|
|
|
|
|
def begin_shutdown() -> None:
|
|
"""Mark the process as shutting down so streaming generators stop looping."""
|
|
_shutting_down.set()
|
|
|
|
|
|
def is_shutting_down() -> bool:
|
|
"""Return ``True`` once the server has begun a graceful shutdown."""
|
|
return _shutting_down.is_set()
|
|
|
|
|
|
def reset_shutdown() -> None:
|
|
"""Clear the shutdown flag. Intended for tests only."""
|
|
_shutting_down.clear()
|