Skip to content

Commit

Permalink
(fix) Changed cookie expiration info parsing in the Kubernetes cookie…
Browse files Browse the repository at this point in the history
…s assistant to tackle the suggestion in the PR review
  • Loading branch information
abel committed Feb 29, 2024
1 parent cee3bfb commit 8cebde5
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions pyinjective/core/network.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,12 +86,11 @@ def _is_cookie_expired(self, cookie_data: str) -> bool:
cookie = SimpleCookie()
cookie.load(cookie_data)

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

Check warning on line 93 in pyinjective/core/network.py

View check run for this annotation

Codecov / codecov/patch

pyinjective/core/network.py#L93

Added line #L93 was not covered by tests

timestamp_diff = expiration_time - time.time()
return timestamp_diff < self.SESSION_RENEWAL_OFFSET
Expand Down

0 comments on commit 8cebde5

Please sign in to comment.