Skip to content

Instantly share code, notes, and snippets.

@lgliducik
Last active December 9, 2016 07:45
Show Gist options
  • Save lgliducik/9b396f33bfc9c767d143 to your computer and use it in GitHub Desktop.
Save lgliducik/9b396f33bfc9c767d143 to your computer and use it in GitHub Desktop.
asyncio_test
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