fix(telegram): add shutdown guard to avoid duplicate restarts

Add a `_shutting_down` flag to `TelegramClient` to suppress disconnect handling during intentional shutdown. The flag is set before sending SIGTERM in `_restart_app` and checked in `_on_disconnect` to ignore those events. Minor formatting adjustments were also applied to `api_server.py` (try block and `uvicorn.run` arguments).
This commit is contained in:
vvzvlad
2026-03-16 04:13:39 +03:00
parent 14f8db0a32
commit 02c29f8692
2 changed files with 10 additions and 5 deletions
+4 -5
View File
@@ -121,12 +121,11 @@ if __name__ == "__main__":
# Log uvloop status
logger.info(" uvloop: enabled (asyncio speedup active)")
try:
try:
uvicorn.run(
"api_server:app",
host=Config["api_host"],
port=Config["api_port"],
reload=True,
"api_server:app",
host=Config["api_host"],
port=Config["api_port"],
loop="uvloop"
)
except OSError as e: