From 8628e39babeba119d544d4676ffdeb26420c5806 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Pierre?= Date: Sat, 14 Sep 2024 11:17:45 +1200 Subject: [PATCH] [Update] server: manual interruption support --- src/py/extra/server.py | 6 +++++- src/py/extra/utils/logging.py | 4 ++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/py/extra/server.py b/src/py/extra/server.py index c93d21f..657ffd3 100644 --- a/src/py/extra/server.py +++ b/src/py/extra/server.py @@ -362,7 +362,11 @@ def run( host=host, port=port, backlog=backlog, condition=condition, timeout=timeout ) app = mount(*components) - asyncio.run(AIOSocketServer.Serve(app, options)) + try: + asyncio.run(AIOSocketServer.Serve(app, options)) + except KeyboardInterrupt: + event("ManualShutdown") + event("EOK") # EOF diff --git a/src/py/extra/utils/logging.py b/src/py/extra/utils/logging.py index 7a5b5f6..2d49211 100644 --- a/src/py/extra/utils/logging.py +++ b/src/py/extra/utils/logging.py @@ -213,7 +213,7 @@ def error( def event( event: str, - value: Any, + value: Any = None, *, origin: str | None = None, at: float | None = None, @@ -235,7 +235,7 @@ def event( def notify( name: str, - value: Any, + value: Any = None, *, origin: str | None = None, at: float | None = None,