Skip to content

Commit 3446035

Browse files
committed
CR
1 parent 88129aa commit 3446035

File tree

2 files changed

+8
-7
lines changed

2 files changed

+8
-7
lines changed

src/firebolt/client/auth/base.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ def _get_cached_token(self) -> Tuple[Optional[str], Optional[int]]:
126126
If caching is disabled, None is returned.
127127
128128
Returns:
129-
Optional[str]: Token if any, and if caching is enabled; None otherwise
129+
Optional[Tuple[Optional[str], Optional[int]]]: Cached token and expiry time
130130
"""
131131
if not self._use_token_cache:
132132
return (None, None)

src/firebolt/utils/cache.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -146,10 +146,11 @@ def _is_expired(self, value: T) -> bool:
146146
def set(self, key: ReprCacheable, value: T, preserve_expiry: bool = False) -> None:
147147
if not self.disabled:
148148
# Set expiry_time for ConnectionInfo objects
149-
if hasattr(value, "expiry_time"):
150-
if not preserve_expiry or value.expiry_time is None:
151-
current_time = int(time.time())
152-
value.expiry_time = current_time + CACHE_EXPIRY_SECONDS
149+
if hasattr(value, "expiry_time") and (
150+
not preserve_expiry or value.expiry_time is None
151+
):
152+
current_time = int(time.time())
153+
value.expiry_time = current_time + CACHE_EXPIRY_SECONDS
153154

154155
s_key = self.create_key(key)
155156
self._cache[s_key] = value
@@ -196,8 +197,8 @@ def __hash__(self) -> int:
196197
def get_cache_data_dir(appname: str = APPNAME) -> str:
197198
"""
198199
Return the directory for storing cache files based on the OS.
199-
Mac: use $TMPDIR
200-
Windows: use the system property 'java.io.tmpdir'
200+
Mac: use $TMPDIR, fallback to /tmp/<appname>
201+
Windows: use the environment variable TEMP or if not defined C:\\Temp
201202
Linux: use $XDG_RUNTIME_DIR, fallback to /tmp/<user_home>
202203
"""
203204

0 commit comments

Comments
 (0)