Last active
December 9, 2016 07:45
-
-
Save lgliducik/9b396f33bfc9c767d143 to your computer and use it in GitHub Desktop.
asyncio_test
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 funcy | |
import requests | |
import aiohttp | |
import asyncio | |
import concurrent.futures | |
pages = ["https://yandex.ru", "https://google.com", "http://selectel.ru"] | |
@asyncio.coroutine | |
def test(name_page): | |
ret = yield from aiohttp.get(name_page) | |
yield from ret.release() | |
@asyncio.coroutine | |
def main(): | |
yield from asyncio.wait([asyncio.async(test(name_page)) for name_page in pages]) | |
if __name__ == "__main__": | |
loop = asyncio.get_event_loop() | |
with funcy.log_durations(print): | |
loop.run_until_complete(main()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment