Added route handler draining during shutdown to promptly close streaming connections.
CI / Formatting (push) Successful in 6s
CI / Linting (push) Successful in 4s
CI / Tests (Python 3.12) (push) Successful in 20s
CI / Tests (Python 3.13) (push) Successful in 53s
CI / Type Checking (push) Has been cancelled
CI / Spelling (push) Has been cancelled
CI / Tests (Python 3.14) (push) Has been cancelled

This commit is contained in:
2026-04-04 10:53:36 -04:00
parent 5425241f74
commit 7e44496baa
3 changed files with 222 additions and 1 deletions
+5
View File
@@ -80,6 +80,7 @@ class HttpServer:
self._runner: web.AppRunner | None = None
self.app = web.Application(middlewares=[_server_header_middleware])
self.app.on_shutdown.append(self._on_shutdown)
self.app.router.add_post(self.config.webhook_path, self._handle_webhook)
# Static assets served from the owlbot package.
@@ -135,6 +136,10 @@ class HttpServer:
await asyncio.gather(*self._pending_tasks)
logger.debug("All pending events drained.")
async def _on_shutdown(self, _app: web.Application) -> None:
"""Drain active route handlers so connections close promptly."""
await self._route_dispatcher.drain_handlers()
async def _handle_webhook(self, request: web.Request) -> web.Response:
"""Handle incoming webhook requests from Owncast."""
try: