Deprecate MovieWriterRegistry cache-dirtyness system.#13567
Deprecate MovieWriterRegistry cache-dirtyness system.#13567dopplershift merged 1 commit intomatplotlib:masterfrom
Conversation
MovieWriterRegistry has a fairly extensive system to cache whether movie writer classes are available or not. Deprecate it and always perform the check every time: for nearly all classes, the availability check is either an import check (Pillow), or checking for whether an executable is in the $PATH -- this is negligible compared to actually running the executable to encode the movie. The only exception is that ffmpeg actually checks whether it is actually ffmpeg or ubuntu's broken libav. In order to avoid performing that check (... which should still be not so slow) when Pillow is available (Pillow is registered first, so comes first :)), add `MovieWriterRegistry.__iter__` which allows to get the first available writer without checking the availability of the subsequent ones (this behavior is consistent with `MovieWriterRegistry.__getitem__` and `MovieWriterRegistry.list`).
efiring
left a comment
There was a problem hiding this comment.
This looks to me like a good simplification, but @dopplershift should have the final say.
| if self.is_available(name): | ||
| yield name | ||
|
|
||
| def list(self): |
There was a problem hiding this comment.
Is this really necessary? Isn't reg.list() just the same as list(reg)?
There was a problem hiding this comment.
Oh, I see. This preserves API.
There was a problem hiding this comment.
Well, I can deprecate it too if you don't mind the API change...
|
I was using 2.2.2 version and "import matplotlib.animation as animation" was stuck when executed in background. I updated to 3.2.2 which fixed that but now it get stuck at "Writer = animation.writers['ffmpeg']" My testcase is quite simple: When I run this file as python3 check.py & it is stuck forever, however when run in foreground it works well. Thanks |
|
@blusingh Can you open as a new issue rather than adding to this PR thread? |
MovieWriterRegistry has a fairly extensive system to cache whether movie
writer classes are available or not. Deprecate it and always perform
the check every time: for nearly all classes, the availability check is
either an import check (Pillow), or checking for whether an executable
is in the $PATH -- this is negligible compared to actually running the
executable to encode the movie.
The only exception is that ffmpeg actually checks whether it is
actually ffmpeg or ubuntu's broken libav. In order to avoid performing
that check (... which should still be not so slow) when Pillow is
available (Pillow is registered first, so comes first :)), add
MovieWriterRegistry.__iter__which allows to get the first availablewriter without checking the availability of the subsequent ones (this
behavior is consistent with
MovieWriterRegistry.__getitem__andMovieWriterRegistry.list).PR Summary
PR Checklist