Debugging Python async code - Step Over

The Step Over function, one of the most basic commands in the debugger panel is pretty much useless when confronted with a line of code starting with await.
What is does is step out of the current function into the parent. Instead it should let the program run until it encounters the next line or until another breakpoint is triggered. Can we have it fixed?

Also the Run to Cursor function doesn't work in such situations. It ends up with:
Exception ignored in: <coroutine object current_function at 0x10bf30410>
RuntimeError: coroutine ignored GeneratorExit

 

2 comments
Comment actions Permalink

This is greatly needed. Debugging normal, non-async python works great, but the default "step over" behavior should be to skip the event loop running. This is probably not happening because technically the await syntax causes python to resume running event loop code (and potentially other tasks on the event loop). Most common debugging doesn't want this behavior, so I currently add a breakpoint after the await and then press play. Only rarely do I need to know what else in the event loop is happening.

3
Comment actions Permalink

Another related feature that may be useful is an "asyncio" interactive console.

For now run I the "apython" script of the "aioconsole" package, but i lose console editing features like readline, highlighting etc.

Are there any solutions that PyCharm team may look into for the near future?

0

Please sign in to leave a comment.