I have python application that I am running in debugging mode.
There are many async functions that i want to check in the debug mode.
So if i write
await abc()
in the debug console it throws an error
Traceback (most recent call last):
File "c:\Users\sgarg\.vscode\extensions\ms-python.python-2021.8.1102490946\pythonFiles\lib\python\debugpy\_vendored\pydevd\_pydevd_bundle\pydevd_vars.py", line 419, in evaluate_expression
compiled = compile(_expression_to_evaluate(expression), '<string>', 'eval')
File "<string>", line 1
a = await abc
^
SyntaxError: invalid syntax
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "c:\Users\sgarg\.vscode\extensions\ms-python.python-2021.8.1102490946\pythonFiles\lib\python\debugpy\_vendored\pydevd\_pydevd_bundle\pydevd_comm.py", line 1207, in internal_evaluate_expression_json
pydevd_vars.evaluate_expression(py_db, frame, expression, is_exec=True)
File "c:\Users\sgarg\.vscode\extensions\ms-python.python-2021.8.1102490946\pythonFiles\lib\python\debugpy\_vendored\pydevd\_pydevd_bundle\pydevd_vars.py", line 371, in new_func
return _run_with_unblock_threads(original_func, py_db, curr_thread, frame, expression, is_exec)
File "c:\Users\sgarg\.vscode\extensions\ms-python.python-2021.8.1102490946\pythonFiles\lib\python\debugpy\_vendored\pydevd\_pydevd_bundle\pydevd_vars.py", line 339, in _run_with_unblock_threads
return _run_with_interrupt_thread(original_func, py_db, curr_thread, frame, expression, is_exec)
File "c:\Users\sgarg\.vscode\extensions\ms-python.python-2021.8.1102490946\pythonFiles\lib\python\debugpy\_vendored\pydevd\_pydevd_bundle\pydevd_vars.py", line 310, in _run_with_interrupt_thread
return original_func(py_db, frame, expression, is_exec)
File "c:\Users\sgarg\.vscode\extensions\ms-python.python-2021.8.1102490946\pythonFiles\lib\python\debugpy\_vendored\pydevd\_pydevd_bundle\pydevd_vars.py", line 421, in evaluate_expression
Exec(_expression_to_evaluate(expression), updated_globals, frame.f_locals)
File "c:\Users\sgarg\.vscode\extensions\ms-python.python-2021.8.1102490946\pythonFiles\lib\python\debugpy\_vendored\pydevd\_pydevd_bundle\pydevd_exec2.py", line 3, in Exec
exec(exp, global_vars, local_vars)
File "<string>", line 1
SyntaxError: 'await' outside function
I tried asyncio
like this
asyncio.run(abc())
and also like this
asyncio.get_event_loop().run_until_complete(abc())
but it shows
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "C:\Users\sgarg\AppData\Local\Programs\Python\Python37\lib\asyncio\base_events.py", line 555, in run_until_complete
self.run_forever()
File "C:\Users\sgarg\AppData\Local\Programs\Python\Python37\lib\asyncio\base_events.py", line 510, in run_forever
raise RuntimeError('This event loop is already running')
RuntimeError: This event loop is already running
it is paused on debug point.
is there any way to solve this?