Commits

Raymond Hettinger  committed b3aeaef

Handle a possible race condition

  • Participants
  • Parent commits e7d545a

Comments (0)

Files changed (1)

File Lib/functools.py

                         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]