Ford's Garage

Small garage of one Ford in the big internet


How to run async functions in debug window / console


Our savior is Ewald de Wit and his nest-asyncio

Installation


python3 -m pip install nest-asyncio

Code


import nest_asyncio

async def main():
    pass  # your code here

loop = asyncio.get_event_loop()
nest_asyncio.apply(loop)
loop.run_until_complete(main())

Now your can run async methods in debug console or window like this:

loop.run_until_complete(your_async_method())