[IPython-dev] Incompatible subclass instances of InteractiveShellEmbed

Darren Dale dsdale24 at gmail.com
Mon Jan 12 12:28:34 EST 2015


The following seems to work for me: in my main hexrd/__init__.py, I do
`from IPython import embed as debug`. Then, in my gui module, I monkeypatch
hexrd.debug so it uses the inprocess qtconsole:

        class Debug(object):
            def __init__(self, shell):
                self.shell = shell
            def __call__(self):
                import inspect
                frame = inspect.currentframe()
                try:
                    # prepare the debug namespace
                    temp = frame.f_back.f_globals
                    temp.update(frame.f_back.f_locals)
                finally:
                    del frame
                # clear and repopulate the qtconsole namespace
                self.shell.run_line_magic('reset', '-f -s')
                self.shell.push(temp)

        hexrd.debug = Debug(kernel_manager.kernel.shell)

Darren

On Sun Jan 11 2015 at 5:49:16 PM Osborn, Raymond <rosborn at anl.gov> wrote:

>  Until someone more knowledgeable replies, this is presumably because
> InteractiveShellEmbed ultimately inherits from SingletonConfigurable, which
> only allows one instance to be created. There is some code in embed.py,
> which saves an existing instance, clears it, and allows another to be
> created:
>
>      saved_shell_instance = InteractiveShell._instance
>     if saved_shell_instance is not None:
>         cls = type(saved_shell_instance)
>         cls.clear_instance()
>     shell = InteractiveShellEmbed.instance(**kwargs)
>
>  If something like that is not in your current code, perhaps you need to
> add it.
>
>  Ray
>
>  On Jan 11, 2015, at 9:37 AM, Darren Dale <dsdale24 at gmail.com> wrote:
>
> Hello,
>
>  I'm working on an application with an in-process qt console, following
> the example at
> https://github.com/ipython/ipython/blob/master/examples/Embedding/inprocess_qtconsole.py
> . I would also like to be able to use the `embed` function occassionally
> for troubleshooting other parts of the application that are unrelated to
> the in-process qt console. However, calling embed yields an error:
> "IPython.config.configurable.MultipleInstanceError: Multiple incompatible
> subclass instances of InteractiveShellEmbed are being created."  I can
> reproduce this with the inprocess example by adding a call to `embed()`
> just before the call to `guisupport.start_event_loop_qt4(app)`. Any ideas
> how to make this work?
>
>  Thanks,
> Darren
>
> _______________________________________________
> IPython-dev mailing list
> IPython-dev at scipy.org
> http://mail.scipy.org/mailman/listinfo/ipython-dev
>
>
> --
> Ray Osborn, Senior Scientist
> Materials Science Division
> Argonne National Laboratory
> Argonne, IL 60439, USA
> Phone: +1 (630) 252-9011
> Email: ROsborn at anl.gov
>
>
>   _______________________________________________
> IPython-dev mailing list
> IPython-dev at scipy.org
> http://mail.scipy.org/mailman/listinfo/ipython-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/ipython-dev/attachments/20150112/7d46578d/attachment.html>


More information about the IPython-dev mailing list