[IPython-dev] migration issues, embedding latest IPython in another application

Matt Anderson manderso@broadcom....
Tue Jul 24 11:15:34 CDT 2012

On Tuesday, July 24, 2012 10:05 AM Thomas Kluyver wrote:

> > Or possibly, at the end of the interactive shell REPL loop, just
> > before control is passed back to the main program (in the case of the
> > embedded shell)?
> Possible but tricky. An embedding program can have a shell object that
> it reuses, so control passes back and forth between the shell and the
> embedding application. The database connection should last while the
> shell does, but as I understand it, __del__ methods are not reliably
> called when the interpreter is shutting down.

It is the calling of self.history_manager.end_session(), I think, during the atexit machinery that is causing the problem.

Could a new session start and the existing session end every time that control passes to, and then back from, an embedded IPython shell? The db object could persist, but the sessions would come and go as control alternated?

If no, would it really be problematic if the db object was not reused? Could the history machinery totally shutdown and start back up as needed? Switching control to and from an embedded shell happens infrequently at most (it is on the timescale of human-computer interaction); would the startup time for creating a new history database connection and its setup be noticeable from the user's perspective?  Or is there some other reason that reusing the db object is desirable (apart from avoiding the time inefficiency of making a new db object several times rather than using the same one repeatedly)?


More information about the IPython-dev mailing list