changeset: 76675:b3aeaef6c315 user: Raymond Hettinger date: Mon Apr 30 14:14:28 2012 -0700 files: Lib/functools.py description: Handle a possible race condition diff -r e7d545a5f6bc -r b3aeaef6c315 Lib/functools.py --- a/Lib/functools.py Mon Apr 30 11:15:38 2012 -0700 +++ b/Lib/functools.py Mon Apr 30 14:14:28 2012 -0700 @@ -241,6 +241,12 @@ return result result = user_function(*args, **kwds) with lock: + if key in cache: + # getting here means that this same key was added to the + # cache while the lock was released. since the link + # update is already done, we need only return the + # computed result and update the count of misses. + pass if currsize < maxsize: # put result in a new link at the front of the queue last = root[PREV]

AltStyle によって変換されたページ (->オリジナル) /