mirror of
https://github.com/tgbot-collection/ytdlbot.git
synced 2024-09-20 15:05:56 +08:00
Prevent race condition
This commit is contained in:
parent
50263b8cad
commit
a783709355
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}"
|
key = f"{chat_id}-{message.id}"
|
||||||
# if the key exists, we shouldn't send edit message
|
# if the key exists, we shouldn't send edit message
|
||||||
if not r.exists(key):
|
if not r.exists(key):
|
||||||
|
r.set(key, "ok", ex=EXPIRE)
|
||||||
msg = f'Uploading {round(current / total * 100, 2)}%: {current}/{total}'
|
msg = f'Uploading {round(current / total * 100, 2)}%: {current}/{total}'
|
||||||
await bot.edit_message(chat_id, message, msg)
|
await bot.edit_message(chat_id, message, msg)
|
||||||
r.set(key, "ok", ex=EXPIRE)
|
|
||||||
|
|
||||||
|
|
||||||
async def sync_edit_message(chat_id, message, msg):
|
async def sync_edit_message(chat_id, message, msg):
|
||||||
# try to avoid flood
|
# try to avoid flood
|
||||||
key = f"{chat_id}-{message.id}"
|
key = f"{chat_id}-{message.id}"
|
||||||
if not r.exists(key):
|
if not r.exists(key):
|
||||||
await bot.edit_message(chat_id, message, msg)
|
|
||||||
r.set(key, "ok", ex=EXPIRE)
|
r.set(key, "ok", ex=EXPIRE)
|
||||||
|
await bot.edit_message(chat_id, message, msg)
|
||||||
|
|
||||||
|
|
||||||
def go(chat_id, message, msg):
|
def go(chat_id, message, msg):
|
||||||
|
|
Loading…
Reference in a new issue