fix(backend): add _legendary_cache_lock for thread-safe games cache access - #168
fix(backend): add _legendary_cache_lock for thread-safe games cache access#168amir-rezaei wants to merge 1 commit into
Conversation
realmaitreal
left a comment
There was a problem hiding this comment.
This declares _legendary_cache_lock = threading.Lock() but never acquires it anywhere. Grepping the file, none of the many read/modify/write sites for _legendary_games_cache (e.g. the check-then-set sequences around the entry = _legendary_games_cache.get(prefix, {}) / _legendary_games_cache[prefix] = entry pairs) are wrapped in with _legendary_cache_lock:.
Since _refresh_legendary_cache is spawned as a background thread from several call sites while other threads can concurrently read/mutate the same cache dict, the race this PR is meant to fix is still there — the lock is currently dead code with no effect. It needs the actual cache access sites wrapped in with _legendary_cache_lock: to do anything.
Generated by Claude Code
Description
This PR adds
_legendary_cache_lockinbackend_server.py.Details
_legendary_games_cachedictionary operations across background scanning and worker threads.