-
Notifications
You must be signed in to change notification settings - Fork 163
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
Caching exceptions. #138
Comments
Kind of thought about that a long while ago, but didn't know how to deal with transient (e.g. network) related exceptions vs. persistent ones (e.g. this URL does not exist). To "decorate cache decorators" as you put it, instead of adding yet another flag, would clearly be a good starting point. Regarding tracebacks... I'm interested, what makes you think these are a "huge NO"? |
As for decorating decorators, the only thing I'd come up would probably be to cumbersome to use:
where |
Good point with "catch-all". In regards to looks I though about: @cached(cache=IncludeExceptions(LRUCache, reraise=True, maxsize=32))
def foo(...): Where 1st argument is cache type and kwargs like Do you think exceptions should be kept in separate "container" than the rest of cached values? My first idea was that all cached values and exceptions sholud share the same container. The traceback object issue I tought of is related to circular dependencies caused by it (https://stackoverflow.com/a/1658335). Keeping them in cache may cause excessive memory usage and make it harder for garbage collector to find cycles. |
Good points! Have to think about it. Don't expect any comments before next weekend (work, life, etc.) ;-) |
Anyway, having a |
Indeed, this looks better. |
Having the same issue I would say 👍 for the selective approach. This way the user can choose between temporary/permanent exception and list them as appropriate. |
BTW, I would be happy to get the same exception reraised as the original. So this should be definitely configurable. |
Hello! @tkem are you currently working on this? Would you be happy to recieve a PR regarding this? |
It's quite embarrassing for me to answer this after more than half a year of inactivity, but somehow this wasn't on my radar... |
I have a usecase where decorated function will raise exceptions for some values and I would like these exceptions to be cached and raised again.
I opened this issue to know if something like this is already implemented or was thought through.
So far what I've though about this is:
cache_exceptions=True
flag to all of them;Your thoughts?
The text was updated successfully, but these errors were encountered: