import asyncio async def foo(loop): print('foo') loop.stop() loop = asyncio.new_event_loop() asyncio.set_event_loop(loop) # <---- asyncio.ensure_future(foo(loop)) loop.run_forever()