mirror of
https://github.com/pyrogram/pyrogram
synced 2025-08-29 13:27:47 +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"
|
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")
|
file = BytesIO() if in_memory else open(temp_file_path, "wb")
|
||||||
|
|
||||||
# noinspection PyBroadException
|
|
||||||
try:
|
try:
|
||||||
async for chunk in self.get_file(file_id, file_size, 0, 0, progress, progress_args):
|
async for chunk in self.get_file(file_id, file_size, 0, 0, progress, progress_args):
|
||||||
file.write(chunk)
|
file.write(chunk)
|
||||||
except BaseException:
|
except BaseException as e:
|
||||||
if not in_memory:
|
if not in_memory:
|
||||||
file.close()
|
file.close()
|
||||||
os.remove(temp_file_path)
|
os.remove(temp_file_path)
|
||||||
|
|
||||||
|
if isinstance(e, asyncio.CancelledError):
|
||||||
|
raise e
|
||||||
|
|
||||||
return None
|
return None
|
||||||
else:
|
else:
|
||||||
if in_memory:
|
if in_memory:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user