We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
pop(args, None)
1 parent 77f10b2 commit a03483dCopy full SHA for a03483d
Doc/library/collections.rst
@@ -1259,8 +1259,12 @@ variants of :func:`functools.lru_cache`:
1259
self.requests.popitem(last=False)
1260
else:
1261
# no longer need to keep track of how many times this
1262
- # entry has been seen
1263
- self.requests.pop(args)
+ # entry has been seen; in a single-threaded environment,
+ # the `requests` OrderedDict will always contain the value
1264
+ # being removed, but use `pop(args, None)` to reduce
1265
+ # complications in a multi-threaded environment where
1266
+ # a race condition may cause an exception
1267
+ self.requests.pop(args, None)
1268
if len(self.cache) == self.maxsize:
1269
self.cache.popitem(last=False)
1270
self.cache[args] = result
0 commit comments