Merge pull request #1784 from GHLuckM4n/master

Remove GLOBAL_GID when queue task cancelled
This commit is contained in:
Anas Tayyar 2024-11-24 20:06:20 +02:00 committed by GitHub
commit 7b86de5518
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -60,10 +60,8 @@ class TelegramDownloadHelper:
async def _on_download_error(self, error):
async with global_lock:
try:
if self._id in GLOBAL_GID:
GLOBAL_GID.remove(self._id)
except:
pass
await self._listener.on_download_error(error)
async def _on_download_complete(self):
@ -148,6 +146,9 @@ class TelegramDownloadHelper:
await send_status_message(self._listener.message)
await event.wait()
if self._listener.is_cancelled:
async with global_lock:
if self._id in GLOBAL_GID:
GLOBAL_GID.remove(self._id)
return
await self._on_download_start(gid, add_to_queue)