Skip to content

Commit

Permalink
Better var name
Browse files Browse the repository at this point in the history
  • Loading branch information
MarkusSintonen committed Jun 11, 2024
1 parent 1077ef7 commit 6819e1c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 10 deletions.
11 changes: 6 additions & 5 deletions httpcore/_async/http11.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,8 @@ def __init__(
our_role=h11.CLIENT,
max_incomplete_event_size=self.MAX_INCOMPLETE_EVENT_SIZE,
)
self._socket_used_at = time.monotonic()
# Assuming we were just connected
self._network_stream_used_at = time.monotonic()

async def handle_async_request(self, request: Request) -> Response:
if not self.can_handle_request(request.url.origin):
Expand Down Expand Up @@ -177,7 +178,7 @@ async def _send_event(
bytes_to_send = self._h11_state.send(event)
if bytes_to_send is not None:
await self._network_stream.write(bytes_to_send, timeout=timeout)
self._socket_used_at = time.monotonic()
self._network_stream_used_at = time.monotonic()

# Receiving the response...

Expand Down Expand Up @@ -229,7 +230,7 @@ async def _receive_event(
data = await self._network_stream.read(
self.READ_NUM_BYTES, timeout=timeout
)
self._socket_used_at = time.monotonic()
self._network_stream_used_at = time.monotonic()

# If we feed this case through h11 we'll raise an exception like:
#
Expand Down Expand Up @@ -294,8 +295,8 @@ def has_expired(self) -> bool:
# only valid state is that the socket is about to return b"", indicating
# a server-initiated disconnect.
# Checking the readable status is relatively expensive so check it at a lower frequency.
if (now - self._socket_used_at) > self._socket_poll_interval():
self._socket_used_at = now
if (now - self._network_stream_used_at) > self._socket_poll_interval():
self._network_stream_used_at = now
server_disconnected = (
self._state == HTTPConnectionState.IDLE
and self._network_stream.get_extra_info("is_readable")
Expand Down
11 changes: 6 additions & 5 deletions httpcore/_sync/http11.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,8 @@ def __init__(
our_role=h11.CLIENT,
max_incomplete_event_size=self.MAX_INCOMPLETE_EVENT_SIZE,
)
self._socket_used_at = time.monotonic()
# Assuming we were just connected
self._network_stream_used_at = time.monotonic()

def handle_request(self, request: Request) -> Response:
if not self.can_handle_request(request.url.origin):
Expand Down Expand Up @@ -177,7 +178,7 @@ def _send_event(
bytes_to_send = self._h11_state.send(event)
if bytes_to_send is not None:
self._network_stream.write(bytes_to_send, timeout=timeout)
self._socket_used_at = time.monotonic()
self._network_stream_used_at = time.monotonic()

# Receiving the response...

Expand Down Expand Up @@ -229,7 +230,7 @@ def _receive_event(
data = self._network_stream.read(
self.READ_NUM_BYTES, timeout=timeout
)
self._socket_used_at = time.monotonic()
self._network_stream_used_at = time.monotonic()

# If we feed this case through h11 we'll raise an exception like:
#
Expand Down Expand Up @@ -294,8 +295,8 @@ def has_expired(self) -> bool:
# only valid state is that the socket is about to return b"", indicating
# a server-initiated disconnect.
# Checking the readable status is relatively expensive so check it at a lower frequency.
if (now - self._socket_used_at) > self._socket_poll_interval():
self._socket_used_at = now
if (now - self._network_stream_used_at) > self._socket_poll_interval():
self._network_stream_used_at = now
server_disconnected = (
self._state == HTTPConnectionState.IDLE
and self._network_stream.get_extra_info("is_readable")
Expand Down

0 comments on commit 6819e1c

Please sign in to comment.