2
0
mirror of https://github.com/pyrogram/pyrogram synced 2025-08-29 13:27:47 +00:00

Add tempfile deletion in case of asyncio task cancellation. (#1080)

This commit is contained in:
Nyan 2022-09-18 11:24:51 -04:00 committed by GitHub
parent 81895d74c7
commit 468ebf50cf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -737,6 +737,12 @@ class Client(Methods):
os.remove(file.name)
return None
except asyncio.CancelledError:
if not in_memory:
file.close()
os.remove(file.name)
raise asyncio.CancelledError()
else:
if in_memory:
file.name = file_name