Skip to content

Don't use stdlib private API in animation.py. #12368

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 1 commit into from
Oct 2, 2018

Conversation

anntzer
Copy link
Contributor

@anntzer anntzer commented Oct 2, 2018

The _std{out,err}_buff attributes on Popen objects don't exist anymore
on Unices (since CPython 3.4). As these buffers are not accessible
anymore in finish(), move the status check and possible exception
throwing to cleanup(), where they are still available.

Don't silently drop exceptions; this shows that ProcessStandin
previously used by HTMLWriter was also buggy (communicate() needed to
return bytes, not str); instead of using it, just do all the work in
finish(), similarly to PillowWriter).

Closes the first part of #9205 (but not #9205 (comment)).

PR Summary

PR Checklist

  • Has Pytest style unit tests
  • Code is Flake 8 compliant
  • New features are documented, with examples if plot related
  • Documentation is sphinx and numpydoc compliant
  • Added an entry to doc/users/next_whats_new/ if major new feature (follow instructions in README.rst there)
  • Documented in doc/api/api_changes.rst if API changed in a backward-incompatible way

Copy link
Member

@WeatherGod WeatherGod left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall, I think this makes sense. Just a couple small notes.

out = TextIOWrapper(BytesIO(out)).read()
err = TextIOWrapper(BytesIO(err)).read()
_log.debug("MovieWriter: stdout: %s", out)
_log.debug("MovieWriter: stderr: %s", err)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you put back the newlines? It helps when reading multi-line output.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sure, this was just copied from the other block. fixed.

return '', ''

self._proc = ProcessStandin()

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is removing this safe? self._run() is still called, I guess it is deferring to a baseclass implementation?

Copy link
Contributor Author

@anntzer anntzer Oct 2, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The parent class (FileMovieWriter) invokes _run in finish:

    def finish(self):
        # Call run here now that all frame grabbing is done. All temp files
        # are available to be assembled.
        self._run()
        MovieWriter.finish(self)  # Will call clean-up

so if we override finish(), we don't call _run() at all.
(TBH I think the inheritance chain of methods could be refactored a bit but that's not the point of this PR.)

Also note that there is actually test coverage for this :)

The _std{out,err}_buff attributes on Popen objects don't exist anymore
on Unices (since CPython 3.4).  As these buffers are not accessible
anymore in finish(), move the status check and possible exception
throwing to cleanup(), where they are still available.

Don't silently drop exceptions; this shows that ProcessStandin
previously used by HTMLWriter was also buggy (communicate() needed to
return bytes, not str); instead of using it, just do all the work in
finish(), similarly to PillowWriter).
@anntzer anntzer force-pushed the animation-subprocess-private branch from 61a0e41 to 02e5358 Compare October 2, 2018 15:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants