Skip to content

Fixed 1656: Animation is Garbage Collected if not explicitly stored #8214

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
wants to merge 8 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
renamed fig.animation to fig._keep_alives
  • Loading branch information
raychut committed Mar 9, 2017
commit d7a3c77c512773556599f45340f46ed0f18b86b0
2 changes: 1 addition & 1 deletion lib/matplotlib/animation.py
Original file line number Diff line number Diff line change
Expand Up @@ -876,7 +876,7 @@ def __init__(self, fig, event_source=None, blit=False):

# Saves the animation is the figure class to prevent Python's garbage
# collection from deleteing the animation.
fig.animations.append(self)
fig._keep_alives.append(self)

def _start(self, *args):
'''
Expand Down
2 changes: 1 addition & 1 deletion lib/matplotlib/figure.py
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,7 @@ def __init__(self,
self._axstack = AxesStack() # track all figure axes and current axes
self.clf()
self._cachedRenderer = None
self.animations = []
self._keep_alives = []

@cbook.deprecated("2.1", alternative="Figure.patch")
def figurePatch(self):
Expand Down
4 changes: 2 additions & 2 deletions lib/matplotlib/tests/test_animation.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ def animate(i):
except UnicodeDecodeError:
pytest.xfail("There can be errors in the numpy import stack, "
"see issues #1891 and #2679")
length = len(fig.animations)
length = len(fig._keep_alives)
assert(length != 0)


Expand All @@ -186,7 +186,7 @@ def update_line(num, data, line):
plt.title('test')
animation.FuncAnimation(fig, update_line,
25, fargs=(data, l), interval=50, blit=True)
length = len(fig.animations)
length = len(fig._keep_alives)
assert(length != 0)


Expand Down