Skip to content

Commit 2c74f62

Browse files
jsonvillanuevapre-commit-ci[bot]MrDiver
authored
Fixed IPython terminal history and embedded shell instatiation for interactive_embed scenes (#3306)
* Fixed IPython sqlite errors/history for interactive_embed scenes * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Add config to instance method --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Tristan Schulz <[email protected]>
1 parent 8ba210f commit 2c74f62

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

manim/scene/scene.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1317,12 +1317,20 @@ def get_embedded_method(method_name):
13171317
# Allow for calling scene methods without prepending 'self.'.
13181318
local_namespace[method] = embedded_method
13191319

1320+
from sqlite3 import connect
1321+
1322+
from IPython.core.getipython import get_ipython
13201323
from IPython.terminal.embed import InteractiveShellEmbed
13211324
from traitlets.config import Config
13221325

13231326
cfg = Config()
13241327
cfg.TerminalInteractiveShell.confirm_exit = False
1325-
shell = InteractiveShellEmbed(config=cfg)
1328+
if get_ipython() is None:
1329+
shell = InteractiveShellEmbed.instance(config=cfg)
1330+
else:
1331+
shell = InteractiveShellEmbed(config=cfg)
1332+
hist = get_ipython().history_manager
1333+
hist.db = connect(hist.hist_file, check_same_thread=False)
13261334

13271335
keyboard_thread = threading.Thread(
13281336
target=ipython,

0 commit comments

Comments
 (0)