mirror of
https://github.com/Mayuri-Chan/pyrofork.git
synced 2026-01-07 07:24:51 +00:00
Re-raise asyncio.CancelledError to avoid continuations
This commit is contained in:
parent
2d547ccf8c
commit
71f263b30d
1 changed files with 4 additions and 2 deletions
|
|
@ -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…
Reference in a new issue