-
Notifications
You must be signed in to change notification settings - Fork 8
Closed
Labels
BugSomething isn't workingSomething isn't working
Description
Thanks for the awesome cache library! When the function raise exception, I found the result will cache 2 records, donot execute new.
import time
import cachebox
start = time.time()
@cachebox.cached(cachebox.TTLCache(128, ttl=10))
def sum_as_string(a, b):
time.sleep(2)
for _ in range(10):
if time.time() - start < 5:
raise ValueError(f"error at {time.time()}")
return str(a + b)
for i in range(10):
try:
tic = time.time()
result = sum_as_string(2, 2)
print(f"{i} result: {result}")
except Exception as e:
print(f"{i} error: {e}")in my computer(centos7, python3.8), the result is:
0 error: error at 1743413726.2670686
1 error: error at 1743413726.2670686
2 error: error at 1743413728.2693837
3 error: error at 1743413728.2693837
4 result: 4
5 result: 4
6 result: 4
7 result: 4
8 result: 4
9 result: 4
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
BugSomething isn't workingSomething isn't working