@@ -71,7 +71,7 @@ def __init__(
7171 our_role = h11 .CLIENT ,
7272 max_incomplete_event_size = self .MAX_INCOMPLETE_EVENT_SIZE ,
7373 )
74- self ._prev_socket_use_time = time .monotonic ()
74+ self ._socket_used_at = time .monotonic ()
7575
7676 async def handle_async_request (self , request : Request ) -> Response :
7777 if not self .can_handle_request (request .url .origin ):
@@ -177,7 +177,7 @@ async def _send_event(
177177 bytes_to_send = self ._h11_state .send (event )
178178 if bytes_to_send is not None :
179179 await self ._network_stream .write (bytes_to_send , timeout = timeout )
180- self ._prev_socket_use_time = time .monotonic ()
180+ self ._socket_used_at = time .monotonic ()
181181
182182 # Receiving the response...
183183
@@ -229,7 +229,7 @@ async def _receive_event(
229229 data = await self ._network_stream .read (
230230 self .READ_NUM_BYTES , timeout = timeout
231231 )
232- self ._prev_socket_use_time = time .monotonic ()
232+ self ._socket_used_at = time .monotonic ()
233233
234234 # If we feed this case through h11 we'll raise an exception like:
235235 #
@@ -294,15 +294,16 @@ def has_expired(self) -> bool:
294294 # only valid state is that the socket is about to return b"", indicating
295295 # a server-initiated disconnect.
296296 # Checking the readable status is relatively expensive so check it at a lower frequency.
297- if (now - self ._prev_socket_use_time ) > self ._socket_poll_interval ():
298- self ._prev_socket_use_time = now
297+ if (now - self ._socket_used_at ) > self ._socket_poll_interval ():
298+ self ._socket_used_at = now
299299 server_disconnected = (
300300 self ._state == HTTPConnectionState .IDLE
301301 and self ._network_stream .get_extra_info ("is_readable" )
302302 )
303- return server_disconnected
304- else :
305- return False
303+ if server_disconnected :
304+ return True
305+
306+ return False
306307
307308 def _socket_poll_interval (self ) -> float :
308309 # Randomize to avoid polling for all the connections at once
0 commit comments