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

当被缓存的对象调用出现异常后,后续的连续调用始终引发 KeyError: '__return__' #2

Open
2018-11-27 opened this issue Jul 1, 2023 · 2 comments
Assignees
Labels
bug Something isn't working

Comments

@2018-11-27
Copy link
Member

当被缓存的对象调用出现异常后,后续的连续调用(在该被缓存的对象引发异常之前的调用)始终引发 KeyError: '__return__'。与 #1 相识。

@2018-11-27 2018-11-27 self-assigned this Jul 1, 2023
@2018-11-27 2018-11-27 added the bug Something isn't working label Jul 1, 2023
@2018-11-27
Copy link
Member Author

经查,系因有关缓存机制设计缺陷所致。当预被缓存的对象调用过程异后,后续的调用(等待缓存值)将得不到缓存值,故引发异常。
修复此问题需重新设计该缓存机制,将在后续择机重构。

2018-11-27 added a commit to 2018-11-27/funccache that referenced this issue Apr 1, 2024
1.Note: This version is a refactored version and many changes are not backward compatible.
2.The scheme of reconstructing the return value of the cache function, uses the secondary lock. Solve the lock contention problem when the function is called concurrently with different parameters.
3.The return value of the method in the cache class supports setting the expiration time.
4.Add a decorator named `count`, supports caching the return value of a function by number of calls.
5.The decorator with cache expiration `expires` is renamed to `ttl`.
6.The cache expiration time parameter can be passed in unit-time (such as "1h40m").
7.Fix issue: When an exception occurs in the call to the cached object, subsequent successive calls always raise `KeyError: '__return__'`. gqylpy#2
8.Fix issue: Concurrent calls when the return value of the function has not been cached or has expired may repeat the execution of the function. gqylpy#4
9.The `__getattribute__` method is no longer silently overridden, and an exception is thrown directly if it exists.
10.Internal code adds type annotations, as well as a lot of optimization and refactoring.
11.Python3.6 and 3.7 are no longer supported.

1.注意:此版本为重构版本,大量改动不向下兼容。
2.重构缓存函数返回值的方案,现采用二级锁。解决以不同参数并发调用函数时的锁竞争问题。
3.缓存类中方法的返回值支持设置过期时间。
4.新增装饰器 `count`,支持按调用次数缓存函数的返回值。
5.带缓存有效期的装饰器 `expires` 更名为 `ttl`。
6.缓存过期时间的参数支持按单位时间(如 "1h40m")的方式传入。
7.修复问题:当被缓存的对象调用出现异常后,后续的连续调用始终引发 `KeyError: '__return__'`。gqylpy#2
8.修复问题:当函数返回值还未被缓存或已过期时的并发调用可能重复执行函数。gqylpy#4
9.不再静默覆盖 `__getattribute__` 方法,如果它存在,将直接抛出异常。
10.内部代码添加类型注解,以及大量优化和重构。
11.Python3.6 和 3.7 版本不再受支持。
@2018-11-27 2018-11-27 mentioned this issue Apr 1, 2024
@2018-11-27
Copy link
Member Author

已重构缓存机制,采用二级执行锁。已修复 #5 ,版本 2.0alpha1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant