Open
Description
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 ptpython 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:
$ ptpython --asyncio
Then:
import aiohttp
print(await asyncio.get('http://foo.com').content)