mirror of
https://github.com/unshackle-dl/unshackle.git
synced 2026-11-14 13:05:09 +00:00
fix(cacher): treat an expiry within 1 µs of now as expired
datetime rounds the expiry to the microsecond, which can land past a coarse time.time() tick (15.6 ms on Windows) and flake test_zero_seconds_expires_now.
This commit is contained in:
@@ -49,8 +49,11 @@ class Cacher:
|
||||
|
||||
@property
|
||||
def expired(self) -> bool:
|
||||
"""Compare as unix time: wall-clock comparison is wrong for an hour at each DST change."""
|
||||
return bool(self.expiration and self.expiration.timestamp() < time.time())
|
||||
"""
|
||||
Compare as unix time: wall-clock comparison is wrong for an hour at each DST change.
|
||||
The 1 µs allowance covers datetime rounding the expiry up past a coarse clock (15.6 ms on Windows).
|
||||
"""
|
||||
return bool(self.expiration and self.expiration.timestamp() < time.time() + 1e-6)
|
||||
|
||||
def get(self, key: str, version: int = 1) -> Cacher:
|
||||
"""
|
||||
|
||||
Reference in New Issue
Block a user