Skip to content

Instantly share code, notes, and snippets.

@amyreese
Created December 31, 2018 05:36
Show Gist options
  • Save amyreese/f70272c926847f6eb87f6c5ca1f6a70e to your computer and use it in GitHub Desktop.
Save amyreese/f70272c926847f6eb87f6c5ca1f6a70e to your computer and use it in GitHub Desktop.
import asyncio
import aiohttp
import logging
import time
from aiomultiprocess import core, Pool
async def get(url):
session = aiohttp.ClientSession()
response = await session.get(url)
session.close()
return await response
async def request():
url = "https://jreese.sh"
urls = [url for _ in range(5)]
async with Pool() as pool:
result = await pool.map(get, urls)
return result
def main():
loop = asyncio.get_event_loop()
loop.run_until_complete(request())
if __name__ == "__main__":
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment