Skip to content

Commit 437386b

Browse files
committed
MNT: tweak MovieWriter.saving to be more cautious
- always try to call `finish` even if an exception is raised. - return `self` so that with writer.saving(...) as mv: mv.grab_frame() works as expected.
1 parent f2c145e commit 437386b

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

lib/matplotlib/animation.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -236,8 +236,10 @@ def saving(self, *args, **kw):
236236
'''
237237
# This particular sequence is what contextlib.contextmanager wants
238238
self.setup(*args, **kw)
239-
yield
240-
self.finish()
239+
try:
240+
yield self
241+
finally:
242+
self.finish()
241243

242244
def _run(self):
243245
# Uses subprocess to call the program for assembling frames into a

0 commit comments

Comments
 (0)