Created
October 18, 2018 20:26
-
-
Save bmbouter/90c1eb9d0b476a0a674930aa33852b56 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 download(session): | |
async with session.get('http://localhost:8080/') as resp: | |
while True: | |
chunk = await resp.content.read(1024) | |
# print(chunk) | |
if not chunk: | |
break | |
print('status={code}'.format(code=resp.status)) | |
async def run(): | |
session = aiohttp.ClientSession() | |
downloaders = [download(session) for i in range(2)] | |
await asyncio.gather(*downloaders) | |
loop = asyncio.get_event_loop() | |
loop.run_until_complete(asyncio.wait([run()])) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment