python_asyncio_course/6_tasks/6_14_111_exceptions.py

17 lines
407 B
Python

import asyncio
from asyncio.exceptions import CancelledError
files = ["image.png", "file.csv", "file1.txt"]
async def download_file(file_name):
pass
async def main():
try:
async with asyncio.TaskGroup() as tg:
tasks = [tg.create_task(download_file(filename)) for filename in files]
except* Exception as err:
for error in err.exceptions:
print(error)