Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 400ea30

Browse files
committed
FIX: Explicitly clean up temporary files in HTMLWriter
- HTMLWriter inherits from FileMovieWriter. - FileMovieWriter create a non-context manager TemporayDirectory on init. - The TemporayDirectory is cleaned up in the cleaup method of FileMovieWriter. - However this method (and its call chain through finish) try to either call a subprocess to merge a bunch of single-frame files into a movie (not relevant) or to clean up such a process (not relevant). - The least disruptive fix is to duplicate the file clean up code.
1 parent cb7c722 commit 400ea30

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

lib/matplotlib/animation.py

+16
Original file line numberDiff line numberDiff line change
@@ -891,6 +891,22 @@ def finish(self):
891891
interval=interval,
892892
**mode_dict))
893893

894+
# duplicate the temporary file clean up logic from
895+
# FileMovieWriter.cleanup. We can not call the inherited
896+
# versions of finished or cleanup because both assume that
897+
# there is a subprocess that we either need to call to merge
898+
# many frames together or that there is a subprocess call that
899+
# we need to clean up.
900+
if self._tmpdir:
901+
_log.debug('MovieWriter: clearing temporary path=%s', self._tmpdir)
902+
self._tmpdir.cleanup()
903+
else:
904+
if self._clear_temp:
905+
_log.debug('MovieWriter: clearing temporary paths=%s',
906+
self._temp_paths)
907+
for path in self._temp_paths:
908+
path.unlink()
909+
894910

895911
class Animation:
896912
"""

0 commit comments

Comments
 (0)