Skip to content

Commit dd1d727

Browse files
committed
MNT: be cautious about pulling from the bg_cache
There are race conditions where _blit_clear may be called before the first draw (which is what will grab the backgrounds)
1 parent 33da7a5 commit dd1d727

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

lib/matplotlib/animation.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -859,7 +859,11 @@ def _blit_clear(self, artists, bg_cache):
859859
# cache and restore.
860860
axes = set(a.axes for a in artists)
861861
for a in axes:
862-
a.figure.canvas.restore_region(bg_cache[a])
862+
try:
863+
a.figure.canvas.restore_region(bg_cache[a])
864+
except KeyError:
865+
# something has happened out of order?
866+
pass
863867

864868
def _setup_blit(self):
865869
# Setting up the blit requires: a cache of the background for the

0 commit comments

Comments
 (0)