Skip to content

Commit 468ebf5

Browse files
authored
Add tempfile deletion in case of asyncio task cancellation. (pyrogram#1080)
1 parent 81895d7 commit 468ebf5

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

pyrogram/client.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -737,6 +737,12 @@ async def handle_download(self, packet):
737737
os.remove(file.name)
738738

739739
return None
740+
except asyncio.CancelledError:
741+
if not in_memory:
742+
file.close()
743+
os.remove(file.name)
744+
745+
raise asyncio.CancelledError()
740746
else:
741747
if in_memory:
742748
file.name = file_name

0 commit comments

Comments
 (0)