(ways, loop, success_files, failure_files)
| 44 | |
| 45 | |
| 46 | async def async_downloader(ways, loop, success_files, failure_files): |
| 47 | async with aiohttp.ClientSession() as session: |
| 48 | coroutines = [ |
| 49 | download_file_by_url( |
| 50 | url, |
| 51 | session=session, |
| 52 | ) |
| 53 | for url in ways |
| 54 | ] |
| 55 | |
| 56 | for task in asyncio.as_completed(coroutines): |
| 57 | fail, url = await task |
| 58 | |
| 59 | if fail: |
| 60 | failure_files.add(url) |
| 61 | else: |
| 62 | success_files.add(url) |
| 63 | |
| 64 | |
| 65 | async def download_file_by_url(url, session=None): |
no test coverage detected