Skip to content
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

Improve the cache miss exception context. #584

Merged
merged 1 commit into from
Apr 2, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@

### Improvements
- More untiled tiff files are handles by the bioformats reader (#569)
- Expose a concurrent option on endpoints for converting images (#583)

### Changes
- Exceptions on cached items are no longer within the KeyError context (#584)

## Version 1.4.3

Expand Down
12 changes: 8 additions & 4 deletions large_image/cache_util/cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,11 +181,15 @@ def __call__(cls, *args, **kwargs): # noqa - N805
key = cls.__name__ + ' ' + key
with cacheLock:
try:
instance = cache[key]
return cache[key]
except KeyError:
instance = super().__call__(*args, **kwargs)
cache[key] = instance
instance._classkey = key
# By passing and handling the cache miss outside of the
# exception, any exceptions while trying to populate the cache
# will not be reported in the cache exception context.
pass
instance = super().__call__(*args, **kwargs)
cache[key] = instance
instance._classkey = key

return instance

Expand Down