A community-maintained Python framework for creating mathematical animations.
Fix some hot reload issues and compatibility with IDEs (#1727)
Ryan McCauley71eb800ed4ba
diff --git a/manim/scene/scene.py b/manim/scene/scene.pyindex 9ec04629d..0dc87c8fc 100644--- a/manim/scene/scene.py+++ b/manim/scene/scene.py@@ -1039,6 +1039,9 @@ class Scene:target=ipython,args=(shell, local_namespace),)+ # run as daemon to kill thread when main thread exits+ if not shell.pt_app:+ keyboard_thread.daemon = Truekeyboard_thread.start()if self.dearpygui_imported and config["enable_gui"]:@@ -1063,7 +1066,7 @@ class Scene:file_observer.start()self.quit_interaction = False- keyboard_thread_needs_join = True+ keyboard_thread_needs_join = shell.pt_app is not Noneassert self.queue.qsize() == 0last_time = time.time()@@ -1073,7 +1076,10 @@ class Scene:if tup[0].startswith("rerun"):# Intentionally skip calling join() on the file thread to save time.if not tup[0].endswith("keyboard"):- shell.pt_app.app.exit(exception=EOFError)+ if shell.pt_app:+ shell.pt_app.app.exit(exception=EOFError)+ file_observer.unschedule_all()+ raise RerunSceneExceptionkeyboard_thread.join()kwargs = tup[2]@@ -1089,10 +1095,11 @@ class Scene:# ]keyboard_thread.join()+ file_observer.unschedule_all()raise RerunSceneExceptionelif tup[0].startswith("exit"):# Intentionally skip calling join() on the file thread to save time.- if not tup[0].endswith("keyboard"):+ if not tup[0].endswith("keyboard") and shell.pt_app:shell.pt_app.app.exit(exception=EOFError)keyboard_thread.join()# Remove exit_keyboard from the queue if necessary.@@ -1120,6 +1127,9 @@ class Scene:while self.queue.qsize() > 0:self.queue.get()+ file_observer.stop()+ file_observer.join()+if self.dearpygui_imported and config["enable_gui"]:dearpygui.core.stop_dearpygui()