New submission from M. Schmitzer: The way the fnmatch module uses its regex cache is not threadsafe. When multiple threads use the module in parallel, a race condition between retrieving a - presumed present - item from the cache and clearing the cache (because the maximum size has been reached) can lead to KeyError being raised.
The attached script demonstrates the problem. Running it will (eventually) yield errors like the following. Exception in thread Thread-10: Traceback (most recent call last): File "/usr/lib/python2.7/threading.py", line 810, in __bootstrap_inner self.run() File "/usr/lib/python2.7/threading.py", line 763, in run self.__target(*self.__args, **self.__kwargs) File "fnmatch_thread.py", line 12, in run fnmatch.fnmatchcase(name, pat) File "/home/marc/.venv/modern/lib/python2.7/fnmatch.py", line 79, in fnmatchcase return _cache[pat].match(name) is not None KeyError: 'lYwrOCJtLU' ---------- components: Library (Lib) files: fnmatch_thread.py messages: 233650 nosy: mschmitzer priority: normal severity: normal status: open title: fnmatch regex cache use is not threadsafe type: crash versions: Python 2.7 Added file: http://bugs.python.org/file37642/fnmatch_thread.py _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue23191> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com