-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Cannot stop/garbage collect an animation #16853
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
Comments
Without having looked at this too much in detail, it seems to come from blitting being used. Would |
@ImportanceOfBeingErnest Nice catch, |
After more thought on it, I found a way to stop the animation which does not rely on the garbage collection of the Animation object (see code below for the record). The behaviour described in the first message of this issue is not anymore an issue for me. Up to you to leave the issue open.
|
The culprit is indeed this line in matplotlib/lib/matplotlib/animation.py Lines 1240 to 1241 in 537a8c9
|
This issue has been marked "inactive" because it has been 365 days since the last comment. If this issue is still present in recent Matplotlib releases, or the feature request is still wanted, please leave a comment and this label will be removed. If there are no updates in another 30 days, this issue will be automatically closed, but you are free to re-open or create a new issue if needed. We value issue reports, and this procedure is meant to help us resurface and prioritize issues that have not been addressed yet, not make them disappear. Thanks for your help! |
|
This seems to be fixed as of master for me; @tacaswell can you confirm or infirm this? |
Bug report
Bug summary
The animation documentation states that the reference to the Animation object must be held to prevent the animation from stopping due to garbage collection. I cannot reproduce this. Also, I do not find any way to stop the animation. I presume the Animation object is held somewhere, and this is undocumented.
The bigger picture for me: I pass as the
frames
argument of FuncAnimation a generator which streams data from a device via a socket. When the generator is garbage collected, the socket is deleted and the device is free to take new connections. Because I cannot garbage collect the Animation object, I cannot garbe collec the socket instrument either and the device hangs.Related #16221
Code for reproduction
Adapted from https://matplotlib.org/3.1.3/api/animation_api.html :
Actual outcome
The animation works.
Expected outcome
The animation should not work, as described in the doc.
Matplotlib version
print(matplotlib.get_backend())
): issue affects at least Qt5Agg and Tk5AggIssue was reproducted in a Python console and in Spyder 4
The text was updated successfully, but these errors were encountered: