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.
This commit is contained in:
penn5 2020-05-13 16:04:05 +01:00 committed by GitHub
parent 393da7e57a
commit 9ba93285f8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -92,6 +92,9 @@ class UserMethods:
self._flood_waited_requests\ self._flood_waited_requests\
[request.CONSTRUCTOR_ID] = time.time() + e.seconds [request.CONSTRUCTOR_ID] = time.time() + e.seconds
if e.seconds == 0:
e.seconds = 1
if e.seconds <= self.flood_sleep_threshold: if e.seconds <= self.flood_sleep_threshold:
self._log[__name__].info(*_fmt_flood(e.seconds, request)) self._log[__name__].info(*_fmt_flood(e.seconds, request))
await asyncio.sleep(e.seconds, loop=self._loop) await asyncio.sleep(e.seconds, loop=self._loop)