'Trying to handle an error but cannot do it! Telegram
I have made a telegram bot using pyrogram to upload a large video and the the progress bar is shown, however the progress bar is repeatedly edited message with new values.
This error message is shown frequently:
Waiting for 3 seconds before continuing (required by "messages.EditMessage")
I am trying to skip this error by try except block
try:
await msg.edit(text=current_message)
except:
pass
but this is not working, the error message still shows up!
What to do?
Solution 1:[1]
The error message you get is Pyrogram handling the FloodWait error from Telegram itself. You can set the sleep_threshold when defining Client() to 0, so you get the actual error you can except yourself. Pyrogram will automatically re-try, whereas you would have to re-implement that again, if you don't want something to go missing in-between.
Alternatively, don't update your Progress Bar as quickly, and increase your increment size. Instead of updating on every single 1% progress, do something like
if progress % 5 == 0:
msg.edit("Progress: {}", format=progress)
This if statement calculates the modulo of your progress, and only updates when it is cleanly divisible by 5. The % operator returns the remainder when dividing your progress.
Also; Pyrograms Documentation about Errors: https://docs.pyrogram.org/api/errors/
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | ColinShark |
