Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit d1941a7

Browse files
authored
Don't try to cleanup CallbackRegistry during interpreter shutd… (#14843)
Don't try to cleanup CallbackRegistry during interpreter shutdown.
2 parents c9edaed + 4233c76 commit d1941a7

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

lib/matplotlib/cbook/__init__.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,12 @@ def connect(self, s, func):
152152
self.callbacks[s][cid] = proxy
153153
return cid
154154

155-
def _remove_proxy(self, proxy):
155+
# Keep a reference to sys.is_finalizing, as sys may have been cleared out
156+
# at that point.
157+
def _remove_proxy(self, proxy, *, _is_finalizing=sys.is_finalizing):
158+
if _is_finalizing():
159+
# Weakrefs can't be properly torn down at that point anymore.
160+
return
156161
for signal, proxies in list(self._func_cid_map.items()):
157162
try:
158163
del self.callbacks[signal][proxies[proxy]]

0 commit comments

Comments
 (0)