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

Matt Anderson manderso@broadcom....
Wed Aug 15 12:15:53 CDT 2012


Hello again,

I know everyone is really busy, and my first emailing was long and detailed, perhaps a challenge to address.  So, I thought I would break it up myself into a couple smaller, more targeted questions.

First question: does the current implementation (v0.13) of the function IPython.embed() have the correct behavior?

It does not seem to participate in the singleton system, and consequently another instance of an InteractiveShell gets created (by the internal IPython machinery) without the config passed to the IPython.embed() function.

To remedy, should the implementation of this function call InteractiveShellEmbed.instance() instead of InteractiveShellEmbed()?

Text from the previous email relating to this is quoted below.

Thanks,
Matt


> Also, I'm not certain if the IPython.embed() function works as
> intended.  It calls the InteractiveShellEmbed class directly to
> construct one, not the InteractiveShellEmbed.instance() method.
> So an interpreter constructed in this way does not participate
> in the singleton system, and the first time one of many things
> happen in the interactive loop (such as an exception being
> thrown), *another* InteractiveShell object gets constructed
> that does not share the config that the InteractiveShellEmbed
> class was passed.  I discovered this after configuring the
> HistoryManager.hist_file configuration setting to
> be ":memory:", and then running a pdb.set_trace() when the
> IPython.core.history.HistorySavingThread was being
> constructed (which should not happen if the hist_file
> is ":memory:").  The singleton that does get constructed was
> trying to open a connection to the default history db file
> location, and so I assume it was constructed with no
> configuration parameters (at least not with the ones I passed
> in).
> 
> Is that the desired behavior?  Or should
> IPython.frontend.terminal.embed.embed() be calling
> InteractiveShellEmbed.instance(**kwargs) instead of
> InteractiveShellEmbed(**kwargs)?





More information about the IPython-dev mailing list