Skip to content

armgit / manim

Public Imported from GitHub
0

A community-maintained Python framework for creating mathematical animations.

Clean up when render raises an error (#1922)

Eric Biedert2dabdb70f9f4
diff --git a/manim/utils/ipython_magic.py b/manim/utils/ipython_magic.py
index 73854d44f..7a9240d03 100644
--- a/manim/utils/ipython_magic.py
+++ b/manim/utils/ipython_magic.py
@@ -123,17 +123,18 @@ else:
)
config.renderer = "cairo"
- SceneClass = local_ns[config["scene_names"][0]]
- scene = SceneClass(renderer)
- scene.render()
-
- # Shader cache becomes invalid as the context is destroyed
- shader_program_cache.clear()
-
- # Close OpenGL window here instead of waiting for the main thread to
- # finish causing the window to stay open and freeze
- if renderer is not None and renderer.window is not None:
- renderer.window.close()
+ try:
+ SceneClass = local_ns[config["scene_names"][0]]
+ scene = SceneClass(renderer=renderer)
+ scene.render()
+ finally:
+ # Shader cache becomes invalid as the context is destroyed
+ shader_program_cache.clear()
+
+ # Close OpenGL window here instead of waiting for the main thread to
+ # finish causing the window to stay open and freeze
+ if renderer is not None and renderer.window is not None:
+ renderer.window.close()
if config["output_file"] is None:
logger.info("No output file produced")