inducer / pudb

Full-screen console debugger for Python
https://documen.tician.de/pudb/
Other
2.96k stars 227 forks source link

pudb does not autoreload file in ipython #105

Open pmcao opened 10 years ago

pmcao commented 10 years ago

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.

asmeurer commented 10 years ago

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.

asmeurer commented 10 years ago

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.

inducer commented 10 years ago

Just call linecache.clearcache() at the right moment. That's where pudb gets its source code.

asmeurer commented 10 years ago

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.

hendrics commented 10 years ago

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.

w-hc commented 1 year ago

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.

inducer commented 1 year ago

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.

asmeurer commented 1 year ago

I wonder if clearing the whole cache could have unindented consequences. Could we clear just the cache for the given file?