Author peter.otten
Recipients Nicolas Savoire, peter.otten, rhettinger, serhiy.storchaka
Date 2016-12-15.10:36:25
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1481798185.65.0.892419002483.issue28969@psf.upfronthosting.co.za>
In-reply-to
Content
Here's another way to reproduce the error. The problem seems to be in the C implementation of _lru_cache_wrapper() / bounded_lru_cache_wrapper().

$ cat test.py
import functools
import threading
import time

@functools.lru_cache(maxsize=2)
def f(v):
    time.sleep(.01)

threads = [threading.Thread(target=f, args=(v,)) for v in [1,2,2,3,2]]
for t in threads:
    t.start()

$ ./python test.py
Exception in thread Thread-5:
Traceback (most recent call last):
  File "/somewhere/Lib/threading.py", line 916, in _bootstrap_inner
    self.run()
  File "/somewhere/Lib/threading.py", line 864, in run
    self._target(*self._args, **self._kwargs)
KeyError: (2,)

$ ./python
Python 3.7.0a0 (default:654ec6ed3225+, Dec 15 2016, 11:24:30) 
[GCC 4.8.4] on linux
History
Date User Action Args
2016-12-15 10:36:25peter.ottensetrecipients: + peter.otten, rhettinger, serhiy.storchaka, Nicolas Savoire
2016-12-15 10:36:25peter.ottensetmessageid: <1481798185.65.0.892419002483.issue28969@psf.upfronthosting.co.za>
2016-12-15 10:36:25peter.ottenlinkissue28969 messages
2016-12-15 10:36:25peter.ottencreate