Experimenting with asyncio righ now is a pain. If I want just to use aiohttp to make a get request, I need to do:
import asyncio
import aiohttp
async def main():
content = await asyncio.get('http://foo.com').content
print(content)
loop = asyncio.get_event_loop()
loop.run_until_complete(main())
Compare to doing the same with requests:
import requets
print(requests.get('http://foo.com').content)
I wish ipython would have an --asyncio option which starts an event loop with the shell and run any command in it.
So my example with aiohttp would become:
Then:
import aiohttp
print(await asyncio.get('http://foo.com').content)
Experimenting with
asynciorigh now is a pain. If I want just to useaiohttpto make a get request, I need to do:Compare to doing the same with
requests:I wish ipython would have an
--asynciooption which starts an event loop with the shell and run any command in it.So my example with
aiohttpwould become:Then: