Skip to content

Commit

Permalink
Merge pull request #2378 from minrk/embed_instance
Browse files Browse the repository at this point in the history
use Singleton.instance() for embed() instead of manual global
  • Loading branch information
fperez committed Sep 6, 2012
2 parents c678a87 + c1d0b69 commit f93f583
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions IPython/frontend/terminal/embed.py
Expand Up @@ -264,8 +264,6 @@ class DummyMod(object):
self.user_ns = orig_user_ns
self.compile.flags = orig_compile_flags

_embedded_shell = None


def embed(**kwargs):
"""Call this to embed IPython at the current point in your program.
Expand All @@ -284,7 +282,7 @@ def embed(**kwargs):
d = 40
embed
Full customization can be done by passing a :class:`Struct` in as the
Full customization can be done by passing a :class:`Config` in as the
config argument.
"""
config = kwargs.get('config')
Expand All @@ -294,7 +292,5 @@ def embed(**kwargs):
config = load_default_config()
config.InteractiveShellEmbed = config.TerminalInteractiveShell
kwargs['config'] = config
global _embedded_shell
if _embedded_shell is None:
_embedded_shell = InteractiveShellEmbed(**kwargs)
_embedded_shell(header=header, stack_depth=2, compile_flags=compile_flags)
shell = InteractiveShellEmbed.instance(**kwargs)
shell(header=header, stack_depth=2, compile_flags=compile_flags)

0 comments on commit f93f583

Please sign in to comment.