Skip to content

Warn when a non-started animation is gc'ed. #18438

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

Closed
anntzer opened this issue Sep 9, 2020 · 1 comment · Fixed by #18445
Closed

Warn when a non-started animation is gc'ed. #18438

anntzer opened this issue Sep 9, 2020 · 1 comment · Fixed by #18445

Comments

@anntzer
Copy link
Contributor

anntzer commented Sep 9, 2020

Bug report

Bug summary

Animations need to be held in a reference so that they are not gc'ed. I have argued against that behavior in #16221, but as long as we keep it, we could at least add an internal flag tracking whether the animation has been started (I have not checked whether it would be best for this to go in _start or _init_draw or elsewhere), and emit a warning in __del__ if the animation is gc'ed without ever being started, to help confused users (https://discourse.matplotlib.org/t/could-animation-be-triggered-only-when-an-onclick-event-in-silder/21534/2). (Unless someone can think of a reason to instantiate an animation and not start it... and even then we could add a flag i_really_meant_for_this_to_be_perhaps_gced_without_ever_running=True, but let's not get ahead of ourselves.)

Code for reproduction

N/A

Matplotlib version

  • Operating system:
  • Matplotlib version: master
  • Matplotlib backend (print(matplotlib.get_backend())):
  • Python version:
  • Jupyter version (if applicable):
  • Other libraries:
@QuLogic
Copy link
Member

QuLogic commented Sep 10, 2020

It appears that using _init_draw is necessary, as _start is never called if you use Animation.save.

QuLogic added a commit to QuLogic/matplotlib that referenced this issue Sep 10, 2020
QuLogic added a commit to QuLogic/matplotlib that referenced this issue Sep 11, 2020
QuLogic added a commit to QuLogic/matplotlib that referenced this issue Sep 11, 2020
danuo pushed a commit to danuo/matplotlib that referenced this issue Sep 11, 2020
@QuLogic QuLogic added this to the v3.4.0 milestone Sep 11, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants