Skip to content

fix(backend): add _legendary_cache_lock for thread-safe games cache access - #168

Open
amir-rezaei wants to merge 1 commit into
mont127:mainfrom
amir-rezaei:fix/backend-legendary-cache-thread-lock
Open

fix(backend): add _legendary_cache_lock for thread-safe games cache access#168
amir-rezaei wants to merge 1 commit into
mont127:mainfrom
amir-rezaei:fix/backend-legendary-cache-thread-lock

Conversation

@amir-rezaei

Copy link
Copy Markdown

Description

This PR adds _legendary_cache_lock in backend_server.py.

Details

  • Provides explicit lock protection for _legendary_games_cache dictionary operations across background scanning and worker threads.

@realmaitreal realmaitreal left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants