From 9ba93285f8c897a0754f2f279aa24a92b916cc3d Mon Sep 17 00:00:00 2001 From: penn5 Date: Wed, 13 May 2020 16:04:05 +0100 Subject: [PATCH] Fix SendMessage FloodWaits on TEST cloud On the TEST cloud, flood waits do not always include the correct number of seconds. The server sends FLOOD_WAIT_0, so Telethon sleeps 0 seconds before retrying. This leads to a ValueError: Request was unsuccessful 6 times. By making a minimum flood wait duration of 1 second, this error is mitigated, as the delay is long enough to avoid the rapid retries, and the request succeeds on the 2nd attempt. For once, I tested this change, and it fixed the issue. --- telethon/client/users.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/telethon/client/users.py b/telethon/client/users.py index 669650df..ddba8ea9 100644 --- a/telethon/client/users.py +++ b/telethon/client/users.py @@ -92,6 +92,9 @@ class UserMethods: self._flood_waited_requests\ [request.CONSTRUCTOR_ID] = time.time() + e.seconds + if e.seconds == 0: + e.seconds = 1 + if e.seconds <= self.flood_sleep_threshold: self._log[__name__].info(*_fmt_flood(e.seconds, request)) await asyncio.sleep(e.seconds, loop=self._loop)