[IPython-user] c++-embedded ipython not preserving history (is in shadowhist only)

Ville M. Vainio vivainio@gmail....
Wed Sep 24 01:44:49 CDT 2008

2008/9/23 Václav Šmilauer <eudoxos@arcig.cz>:

> Once ipshell() returns (^D), pyRun_SimpleFile returns as well and the
> whole program terminates.
> Next time I run, history from the previous session doesn's show up,
> although grepping through ~/.ipython/db/shadowhist/* shows that those
> commands were actually saved there, but not in ~/.ipython/history.

Ipython saves the readline history in "atexit" handler
(atexit_operations()). It was not run because the python interpreter
was not destroyed (and atexit handler not run). If you are running
from python code, atexit handler still gets run when the python
process is ended.

You can get around this by running atexit_operations yourself when you
exit. Though it may be that we should really run atexit_operations
when we leave ipython session, as opposed to relying on atexit handler

Perhaps you can try modding iplib.py by adding
self.atexit_operations() in the end of interact() after while loop.

Ville M. Vainio

More information about the IPython-user mailing list