[Python-ideas] Make asyncio.get_event_loop a builtin

Ken Hilton kenlhilton at gmail.com
Tue May 22 05:21:17 EDT 2018

Hi all,

Just a simple idea I wanted to bring forth. Although I know that you get a
lot more asyncio control by importing the asyncio module itself, I'd like
to see a way to make simple asynchronous applications without ever
importing asyncio itself. To that end, I propose making
asyncio.get_event_loop() a builtin. This would enable simple things like
this (example copied from websockets.readthedocs.io with slight

    import websockets

    async def hello():
        async with websockets.connect('wss://echo.websocket.org') as ws:
            amsg = 'a message'

            print(f'> {amsg}')
            await ws.send(amsg)

            ret = await ws.recv()
            print(f'< {ret}')


See how that never imported asyncio? I just think it would be more
convenient this way. But there may be major problems that I hadn't
anticipated, so as always:


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20180522/6e514c51/attachment.html>

More information about the Python-ideas mailing list