FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

gh-142763: Fix race in ZoneInfo cache eviction by colesbury · Pull Request #144978 · python/cpython · GitHub

/ cpython Public
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .py  (1) .rst  (1) All 2 file types selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
6 changes: 5 additions & 1 deletion Lib/zoneinfo/_zoneinfo.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,11 @@ def __new__(cls, key):
cls._strong_cache[key] = cls._strong_cache.pop(key, instance)

if len(cls._strong_cache) > cls._strong_cache_size:
cls._strong_cache.popitem(last=False)
try:
cls._strong_cache.popitem(last=False)
except KeyError:
# another thread may have already emptied the cache
pass

return instance

Expand Down
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Fix a race condition between :class:`zoneinfo.ZoneInfo` creation and
:func:`zoneinfo.ZoneInfo.clear_cache` that could raise :exc:`KeyError`.
Loading

Back | FazBrowse Home | New Git URL