Skip to content

Commit

Permalink
order
Browse files Browse the repository at this point in the history
  • Loading branch information
bdraco committed Sep 19, 2024
1 parent 8539283 commit 26a12e4
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions aiohttp/cookiejar.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,9 +107,8 @@ def __init__(
for url in treat_as_secure_origin
}
)
self._expirations: Dict[Tuple[str, str, str], float] = {}
# heap of cookies by expiration time
self._expire_heap: List[Tuple[float, str, str, str]] = []
self._expirations: Dict[Tuple[str, str, str], float] = {}

def save(self, file_path: PathLike) -> None:
file_path = pathlib.Path(file_path)
Expand All @@ -123,10 +122,10 @@ def load(self, file_path: PathLike) -> None:

def clear(self, predicate: Optional[ClearCookiePredicate] = None) -> None:
if predicate is None:
self._expire_heap.clear()
self._cookies.clear()
self._host_only_cookies.clear()
self._expirations.clear()
self._expire_heap.clear()
return

now = time.time()
Expand Down Expand Up @@ -193,8 +192,8 @@ def _delete_cookies(self, to_del: List[Tuple[str, str, str]]) -> None:
self._expirations.pop((domain, path, name), None)

def _expire_cookie(self, when: float, domain: str, path: str, name: str) -> None:
self._expirations[(domain, path, name)] = when
heapq.heappush(self._expire_heap, (when, domain, path, name))
self._expirations[(domain, path, name)] = when

def update_cookies(self, cookies: LooseCookies, response_url: URL = URL()) -> None:
"""Update cookies."""
Expand Down

0 comments on commit 26a12e4

Please sign in to comment.