diff options
author | Raymond Hettinger <python@rcn.com> | 2013-03-01 11:47:57 (GMT) |
---|---|---|
committer | Raymond Hettinger <python@rcn.com> | 2013-03-01 11:47:57 (GMT) |
commit | fd54117a682224200ce057a60b0205b0e13948d2 (patch) | |
tree | 7e9a909704f5a02b6a52bd3e7a1a0a31a09fad50 /Lib | |
parent | faaba59977036da9f4179ef426e0862251110ba0 (diff) | |
download | cpython-fd54117a682224200ce057a60b0205b0e13948d2.zip cpython-fd54117a682224200ce057a60b0205b0e13948d2.tar.gz cpython-fd54117a682224200ce057a60b0205b0e13948d2.tar.bz2 |
Don't deadlock on a reentrant call.
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/functools.py | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/Lib/functools.py b/Lib/functools.py index 226a46e..71022e5 100644 --- a/Lib/functools.py +++ b/Lib/functools.py @@ -14,9 +14,9 @@ __all__ = ['update_wrapper', 'wraps', 'WRAPPER_ASSIGNMENTS', 'WRAPPER_UPDATES', from _functools import partial, reduce from collections import namedtuple try: - from _thread import allocate_lock as Lock + from _thread import RLock except: - from _dummy_thread import allocate_lock as Lock + from dummy_threading import RLock ################################################################################ @@ -207,7 +207,7 @@ def lru_cache(maxsize=128, typed=False): hits = misses = currsize = 0 full = False cache_get = cache.get # bound method to lookup a key or return None - lock = Lock() # because linkedlist updates aren't threadsafe + lock = RLock() # because linkedlist updates aren't threadsafe root = [] # root of the circular doubly linked list root[:] = [root, root, None, None] # initialize by pointing to self |