fix(telegram): wait for application readiness

This commit is contained in:
Xubin Ren authored and chengyongru committed 2026-08-18 00:41:57 +08:00
1 parent 302015fde5
commit 8a928592c5
2 files changed
+85 -54

No files matched your search

+2 -2
View File
@@ -736,13 +736,13 @@ class TelegramChannel(BaseChannel):
the message as delivered, so raise once the wait runs out. None means the
channel is stopped: nothing left to deliver.
"""
if self._app is not None:
if self._app_ready.is_set() and self._app is not None:
return self._app
if not self._running:
return None
with suppress(asyncio.TimeoutError):
await asyncio.wait_for(self._app_ready.wait(), APP_RESTART_SEND_WAIT_SECONDS)
if self._app is None:
if not self._app_ready.is_set() or self._app is None:
raise RuntimeError("Telegram application is restarting; message not delivered")
return self._app