-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathexample_async.py
More file actions
30 lines (20 loc) · 810 Bytes
/
example_async.py
File metadata and controls
30 lines (20 loc) · 810 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
"""
Example usage for the downloader in async mode. It shows how to download a single and
multiple files file with the downloader
"""
import logging
import asyncio
import aiodownloader
logging.basicConfig(level='DEBUG')
async def download_async():
downloader = aiodownloader.Handler(sync=False)
# Downloading a file
await downloader.download('https://media.giphy.com/media/Vuw9m5wXviFIQ/giphy.gif')
await downloader.download(*[
'https://www.visualstudio.com/wp-content/uploads/2016/06/python-1-562x309@2x-op.png',
'https://media.giphy.com/media/Vuw9m5wXviFIQ/giphy.gif',
'https://cdn-images-1.medium.com/max/800/1*6V7WZZ5rhCWJvRzevnAh5g.png',
])
if __name__ == '__main__':
loop = asyncio.get_event_loop()
loop.run_until_complete(download_async())