mirror of
https://github.com/pyrogram/pyrogram
synced 2025-08-28 21:07:59 +00:00
Re-raise asyncio.CancelledError to avoid continuations
This commit is contained in:
parent
2d547ccf8c
commit
71f263b30d
@ -730,15 +730,17 @@ class Client(Methods):
|
||||
temp_file_path = os.path.abspath(re.sub("\\\\", "/", os.path.join(directory, file_name))) + ".temp"
|
||||
file = BytesIO() if in_memory else open(temp_file_path, "wb")
|
||||
|
||||
# noinspection PyBroadException
|
||||
try:
|
||||
async for chunk in self.get_file(file_id, file_size, 0, 0, progress, progress_args):
|
||||
file.write(chunk)
|
||||
except BaseException:
|
||||
except BaseException as e:
|
||||
if not in_memory:
|
||||
file.close()
|
||||
os.remove(temp_file_path)
|
||||
|
||||
if isinstance(e, asyncio.CancelledError):
|
||||
raise e
|
||||
|
||||
return None
|
||||
else:
|
||||
if in_memory:
|
||||
|
Loading…
x
Reference in New Issue
Block a user