mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
[3.13] gh-126775: make linecache.checkcache threadsafe and GC re-entrency safe (GH-126776) (#127778)
gh-126775: make linecache.checkcache threadsafe and GC re-entrency safe (GH-126776)
(cherry picked from commit 2233c303e4
)
Co-authored-by: Thomas Grainger <tagrain@gmail.com>
Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>
Co-authored-by: Bartosz Sławecki <bartoszpiotrslawecki@gmail.com>
This commit is contained in:
parent
6441d42f92
commit
9d0252ff2e
2 changed files with 9 additions and 5 deletions
|
@ -49,14 +49,17 @@ def checkcache(filename=None):
|
|||
(This is not checked upon each call!)"""
|
||||
|
||||
if filename is None:
|
||||
filenames = list(cache.keys())
|
||||
elif filename in cache:
|
||||
filenames = [filename]
|
||||
# get keys atomically
|
||||
filenames = cache.copy().keys()
|
||||
else:
|
||||
return
|
||||
filenames = [filename]
|
||||
|
||||
for filename in filenames:
|
||||
entry = cache[filename]
|
||||
try:
|
||||
entry = cache[filename]
|
||||
except KeyError:
|
||||
continue
|
||||
|
||||
if len(entry) == 1:
|
||||
# lazy cache entry, leave it lazy.
|
||||
continue
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue