Skip to content

Commit 8cebde5

Browse files
author
abel
committed
(fix) Changed cookie expiration info parsing in the Kubernetes cookies assistant to tackle the suggestion in the PR review
1 parent cee3bfb commit 8cebde5

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

pyinjective/core/network.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -86,12 +86,11 @@ def _is_cookie_expired(self, cookie_data: str) -> bool:
8686
cookie = SimpleCookie()
8787
cookie.load(cookie_data)
8888

89-
if "GCLB" not in cookie:
89+
expiration_data: Optional[str] = cookie.get("GCLB", {}).get("expires", None)
90+
if expiration_data is None:
9091
expiration_time = 0
9192
else:
92-
expiration_time = datetime.datetime.strptime(
93-
cookie["GCLB"]["expires"], "%a, %d-%b-%Y %H:%M:%S %Z"
94-
).timestamp()
93+
expiration_time = datetime.datetime.strptime(expiration_data, "%a, %d-%b-%Y %H:%M:%S %Z").timestamp()
9594

9695
timestamp_diff = expiration_time - time.time()
9796
return timestamp_diff < self.SESSION_RENEWAL_OFFSET

0 commit comments

Comments
 (0)