Created
December 31, 2018 05:36
-
-
Save amyreese/f70272c926847f6eb87f6c5ca1f6a70e 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 | |
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