Skip to content

MNT: tweak MovieWriter.saving to be more cautious #7606

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.
  • Loading branch information
tacaswell committed Dec 11, 2016
commit 437386b35bcecc362abc37f97ebac5c0b2dceebf
6 changes: 4 additions & 2 deletions lib/matplotlib/animation.py
Original file line number Diff line number Diff line change
Expand Up @@ -236,8 +236,10 @@ def saving(self, *args, **kw):
'''
# This particular sequence is what contextlib.contextmanager wants
self.setup(*args, **kw)
yield
self.finish()
try:
yield self
finally:
self.finish()

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