Skip to content

Improved exception handling on animation failure #12369

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 9, 2018

Conversation

anntzer
Copy link
Contributor

@anntzer anntzer commented Oct 2, 2018

PR Summary

Previously, if an animation-generating subprocess (e.g. ffmpeg)
failed while data was piped in, we'd get a ValueError because we'd
communicate() with the subprocess once in grab_frame(), to generate a
first error, and again at cleanup time, in the finally: clause, but that
second time, the subprocess' stdout and stderr had already been closed.

Instead, don't do anything in grab_frame() and let the finally: clause
handle the errors.

Also replace the nondescript RuntimeError by a CalledProcessError, which
is more descriptive, generates a proper error message by itself
("Command 'foo' returned non-zero exit status 42") and is more easily
introspectable (it includes stdout, stderr as attributes). Given that
we would previously sometimes throw a ValueError instead of the intended
RuntimeError, I think the API change is worth it.

Un-xfail a test.

Builds on top of #12368. Closes the second half of #9205.

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

@anntzer anntzer requested a review from dopplershift October 2, 2018 12:00
@anntzer anntzer force-pushed the animation-failure branch from d7a7107 to ba0bfe3 Compare October 2, 2018 12:09
@anntzer anntzer changed the title Animation failure Improved exception handling on animation failure Oct 2, 2018
@dopplershift
Copy link
Contributor

So will this need a rebase once #12368 is in? A lot of the changes look the same.

Otherwise, in principle I'm 👍 on the change. The exception change seems worth it to me.

@anntzer anntzer force-pushed the animation-failure branch from ba0bfe3 to 238a50e Compare October 2, 2018 20:05
@anntzer
Copy link
Contributor Author

anntzer commented Oct 2, 2018

the first commit was shared, rebased this pr now that the other is merged.

@QuLogic QuLogic added this to the v3.1 milestone Oct 3, 2018
Copy link
Member

@timhoffm timhoffm left a comment

Choose a reason for hiding this comment

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

Please rebase, since #12366 is in and should fix the CI errors.

@anntzer
Copy link
Contributor Author

anntzer commented Oct 3, 2018

done

Previously, if an animation-generating subprocess (e.g. ffmpeg)
failed while data was piped in, we'd get a ValueError because we'd
communicate() with the subprocess once in grab_frame(), to generate a
first error, and again at cleanup time, in the finally: clause, but that
second time, the subprocess' stdout and stderr had already been closed.

Instead, don't do anything in grab_frame() and let the finally: clause
handle the errors.

Also replace the nondescript RuntimeError by a CalledProcessError, which
is more descriptive, generates a proper error message by itself
("Command 'foo' returned non-zero exit status 42") and is more easily
introspectable (it includes stdout, stderr as attributes).  Given that
we would previously sometimes throw a ValueError instead of the intended
RuntimeError, I think the API change is worth it.

Un-xfail a test.
@anntzer anntzer force-pushed the animation-failure branch from d1f2178 to 258c53b Compare October 3, 2018 10:17
@jklymak
Copy link
Member

jklymak commented Oct 4, 2018

ping @dopplershift for a review when you have time....

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.

5 participants