I usually like to call some functions during debugging in the console just to see some quick results. However with async functions, this doesn't seem to be possible:
import asyncio
async def func1():
print('func1')
def func2():
print('func2')
async def main():
task = asyncio.create_task(func1())
await task # put a break point here
asyncio.run(main())
Let's say we put a break point in the line of await task
Now if I call func2() in the console it will print 'func2' perfectly fine.
However, if I enter await task in console, I will get the below error:
File ".../anaconda3/lib/python3.9/asyncio/base_events.py", line 585, in _check_running
raise RuntimeError(
RuntimeError: Cannot run the event loop while another loop is running
python 3.9 pycharm 2022.3.1
Is there any way I can call the async functions in the console like the non-async functions?