mirror of
https://github.com/tgbot-collection/ytdlbot.git
synced 2024-11-10 09:12:45 +08:00
Prevent race condition
This commit is contained in:
parent
50263b8cad
commit
a783709355
1 changed files with 2 additions and 2 deletions
4
ytdl.py
4
ytdl.py
|
@ -38,17 +38,17 @@ async def upload_callback(current, total, chat_id, message):
|
|||
key = f"{chat_id}-{message.id}"
|
||||
# if the key exists, we shouldn't send edit message
|
||||
if not r.exists(key):
|
||||
r.set(key, "ok", ex=EXPIRE)
|
||||
msg = f'Uploading {round(current / total * 100, 2)}%: {current}/{total}'
|
||||
await bot.edit_message(chat_id, message, msg)
|
||||
r.set(key, "ok", ex=EXPIRE)
|
||||
|
||||
|
||||
async def sync_edit_message(chat_id, message, msg):
|
||||
# try to avoid flood
|
||||
key = f"{chat_id}-{message.id}"
|
||||
if not r.exists(key):
|
||||
await bot.edit_message(chat_id, message, msg)
|
||||
r.set(key, "ok", ex=EXPIRE)
|
||||
await bot.edit_message(chat_id, message, msg)
|
||||
|
||||
|
||||
def go(chat_id, message, msg):
|
||||
|
|
Loading…
Reference in a new issue