pudb
pudb copied to clipboard
pudb does not autoreload file in ipython
Hi there,
When using pudb with ipython, e.g.,
%pudb test.py
It does not automatically reload the file when I edit the file using external editors. Could you please suggest a fix? Thanks.
It's not clear to me why it wouldn't work. It uses execfile (exec in Python 3), which should reload the file if it's changed.
Ah, I see the issue. The file is reloaded, but the display is cached against the old version. But if you step through the file you'll see that it really is running the new version. So the display needs to be refreshed.
Just call linecache.clearcache()
at the right moment. That's where pudb gets its source code.
What would be the right moment? I tried adding it at https://github.com/inducer/pudb/blob/master/pudb/debugger.py#L370, but that didn't work.
i am facing the same problem. The file seemed to be cached. Only when i load a different file and then load the same one, then it is being reloaded.
Are there follow-ups to this issue, or ways in which I can contribute to help with the problem? It's a critical feature for me. I use IPython + pudb because my workload usually involves a compute-heavy init step. I use IPython to cache that state, so that working across sessions/edits is fast.
This could be as simple as calling linecache.clearcache
upon entry to the debugger. A PR that does that (with an explanatory comment) would be welcome, if that solves the problem for you all.
I wonder if clearing the whole cache could have unindented consequences. Could we clear just the cache for the given file?