-
-
Notifications
You must be signed in to change notification settings - Fork 10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Utkarsh/issue 186 #189
Utkarsh/issue 186 #189
Conversation
Made cache removal safer by using a lock to avoid repeated checks
🔍 Existing Issues For ReviewYour pull request is modifying functions with the following pre-existing issues: 📄 File: pv_site_api/cache.py
Did you find this useful? React with a 👍 or 👎 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @Sigma-Verma for this.
Do you mind fixing the linting, see CI?
This seems a really good way to do it, with thread locking. Do you know how this works if two calls to the api are made very close to each other? Does this then slow down the second one? Perhaps this is the only way to do it?
Perhaps there's a speed up here, where we check if these items are cache locked, and if so carry on and do nothing
added old-cache-check for skipping unnecessary processing, improving response time
hey can you guide me on how to fix the Linting ? |
pv_site_api/cache.py
Outdated
logger.debug(f"Memory is {process.memory_info().rss / 10 ** 6} MB") | ||
|
||
return last_updated, response | ||
now = datetime.now(tz=timezone.utc) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this identented correctly?
Also, do you mind incorporating #199? |
minor indent fixes
keys_to_remove.append(key) | ||
|
||
with cache_lock: | ||
for key, value in last_updated.items(): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could you include the .copy() that i added please
Made cache removal safer by using a lock to avoid repeated checks
Pull Request
Description
Enhanced thread safety by consolidating cache removal logic within a lock, preventing redundant iterations and ensuring consistent access to shared data.
Checklist: