One task per user

This commit is contained in:
yasir 2023-01-28 11:43:04 +07:00
parent c7b0b25c08
commit 1a89ecc7b5
2 changed files with 7 additions and 6 deletions

View file

@ -45,7 +45,7 @@ async def genss(client, message):
if not DL_TASK.get(message.from_user.id):
DL_TASK[message.from_user.id] = Lock()
if DL_TASK[message.from_user.id].locked():
if DL_TASK.get(message.from_user.id):
return await process.edit("Sorry to avoid flood and error, bot only process one task at a time.")
c_time = time.time()
the_real_download_location = await replied.download(

View file

@ -29,12 +29,13 @@ async def mediainfo(client, message):
file_info = get_file_id(message.reply_to_message)
if file_info is None:
return await process.edit_text("Balas ke format media yang valid")
if not DL_TASK.get(message.from_user.id):
DL_TASK[message.from_user.id] = asyncio.Lock()
async with DL_TASK:
if not DL_TASK.get(message.from_user.id):
DL_TASK[message.from_user.id] = asyncio.Lock()
if DL_TASK[message.from_user.id].locked():
return await process.edit("Sorry to avoid flood and error, bot only process one task at a time.")
if DL_TASK.get(message.from_user.id):
return await process.edit("Sorry to avoid flood and error, bot only process one task at a time.")
c_time = time.time()
file_path = await message.reply_to_message.download(
progress=progress_for_pyrogram,