Skip to content
This repository was archived by the owner on Dec 23, 2024. It is now read-only.

Commit 71f263b

Browse files
committed
Re-raise asyncio.CancelledError to avoid continuations
1 parent 2d547cc commit 71f263b

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

pyrogram/client.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -730,15 +730,17 @@ async def handle_download(self, packet):
730730
temp_file_path = os.path.abspath(re.sub("\\\\", "/", os.path.join(directory, file_name))) + ".temp"
731731
file = BytesIO() if in_memory else open(temp_file_path, "wb")
732732

733-
# noinspection PyBroadException
734733
try:
735734
async for chunk in self.get_file(file_id, file_size, 0, 0, progress, progress_args):
736735
file.write(chunk)
737-
except BaseException:
736+
except BaseException as e:
738737
if not in_memory:
739738
file.close()
740739
os.remove(temp_file_path)
741740

741+
if isinstance(e, asyncio.CancelledError):
742+
raise e
743+
742744
return None
743745
else:
744746
if in_memory:

0 commit comments

Comments
 (0)