vmprof-python
vmprof-python copied to clipboard
Python 3.5 async/await seems to yield wrong stack traces
vmprof just walks the stack traces. this can be problematic for when async/await is used. need to flesh out some details how it works and what vmprof should do different in such cases.
Here is a sample from @njsmith https://gist.github.com/njsmith/1c3742362bb6f5cc505f69cb66db2e71
NB I just updated the example gist to give a bit more details.
In a truly baffling turn of events, I can no longer reproduce the weird results in that gist -- rerunning the exact same command line now gives me more sensible results.
Okay, figured it out... the issue is that if you re-enter a coroutine/generator stack via send, then everything works as you'd expect. But if you re-enter using throw, then you get the weird thing I saw before. (This is on CPython only -- PyPy gives sensible results in both cases.)
Self-container reproducer: https://gist.github.com/njsmith/d566941ee3566f2c69f45c5bab65eb51
filed upstream: https://bugs.python.org/issue29590