Created
August 9, 2018 21:27
-
-
Save bmbouter/8665d36b1175ce8176ce63e7b403a906 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import asyncio | |
import aiohttp | |
async def my_download(): | |
with open('/tmp/somefileintmp', 'wb') as the_file: | |
async with aiohttp.ClientSession(auto_decompress=False) as session: | |
async with session.get('https://repos.fedorapeople.org/pulp/pulp/fixtures/python-pypi/packages/shelf_reader-0.1-py2-none-any.whl') as resp: | |
while True: | |
chunk = await resp.content.read(1024 * 1024) | |
if not chunk: | |
break # the download is done | |
the_file.write(chunk) | |
loop = asyncio.get_event_loop() | |
loop.run_until_complete(my_download()) | |
loop.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment