Commit 3e37f4a1 authored by INADA Naoki's avatar INADA Naoki Committed by Łukasz Langa

bpo-29519: weakref spewing exceptions during interp finalization (#2958)

(cherry pick from 9cd7e176)
parent fa90179e
......@@ -53,7 +53,7 @@ class WeakValueDictionary(UserDict.UserDict):
args = args[1:]
if len(args) > 1:
raise TypeError('expected at most 1 arguments, got %d' % len(args))
def remove(wr, selfref=ref(self)):
def remove(wr, selfref=ref(self), _atomic_removal=_remove_dead_weakref):
self = selfref()
if self is not None:
if self._iterating:
......@@ -61,7 +61,7 @@ class WeakValueDictionary(UserDict.UserDict):
else:
# Atomic removal is necessary since this function
# can be called asynchronously by the GC
_remove_dead_weakref(self.data, wr.key)
_atomic_removal(self.data, wr.key)
self._remove = remove
# A list of keys to be removed
self._pending_removals = []
......
Fix weakref spewing exceptions during interpreter shutdown when used with a
rare combination of multiprocessing and custom codecs.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment