Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/httpcore2/httpcore2/_async/http11.py
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,10 @@ def is_available(self) -> bool:

def has_expired(self) -> bool:
now = time.monotonic()
keepalive_expired = self._expire_at is not None and now > self._expire_at
# Read `_expire_at` once into a local: on free-threaded builds another
# thread may reset it to `None` between the check and the comparison.
expire_at = self._expire_at
keepalive_expired = expire_at is not None and now > expire_at

# If the HTTP connection is idle but the socket is readable, then the
# only valid state is that the socket is about to return b"", indicating
Expand Down
5 changes: 4 additions & 1 deletion src/httpcore2/httpcore2/_async/http2.py
Original file line number Diff line number Diff line change
Expand Up @@ -484,7 +484,10 @@ def is_available(self) -> bool:

def has_expired(self) -> bool:
now = time.monotonic()
return self._expire_at is not None and now > self._expire_at
# Read `_expire_at` once into a local: on free-threaded builds another
# thread may reset it to `None` between the check and the comparison.
expire_at = self._expire_at
return expire_at is not None and now > expire_at

def is_idle(self) -> bool:
return self._state == HTTPConnectionState.IDLE
Expand Down
5 changes: 4 additions & 1 deletion src/httpcore2/httpcore2/_sync/http11.py
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,10 @@ def is_available(self) -> bool:

def has_expired(self) -> bool:
now = time.monotonic()
keepalive_expired = self._expire_at is not None and now > self._expire_at
# Read `_expire_at` once into a local: on free-threaded builds another
# thread may reset it to `None` between the check and the comparison.
expire_at = self._expire_at
keepalive_expired = expire_at is not None and now > expire_at

# If the HTTP connection is idle but the socket is readable, then the
# only valid state is that the socket is about to return b"", indicating
Expand Down
5 changes: 4 additions & 1 deletion src/httpcore2/httpcore2/_sync/http2.py
Original file line number Diff line number Diff line change
Expand Up @@ -484,7 +484,10 @@ def is_available(self) -> bool:

def has_expired(self) -> bool:
now = time.monotonic()
return self._expire_at is not None and now > self._expire_at
# Read `_expire_at` once into a local: on free-threaded builds another
# thread may reset it to `None` between the check and the comparison.
expire_at = self._expire_at
return expire_at is not None and now > expire_at

def is_idle(self) -> bool:
return self._state == HTTPConnectionState.IDLE
Expand Down
Loading