@@ -241,15 +241,11 @@ async def handle_async_request(self, request: Request) -> Response:
241241 response = await connection .handle_async_request (
242242 pool_request .request
243243 )
244- except ConnectionNotAvailable :
245- # In some cases a connection may initially be available to
246- # handle a request, but then become unavailable.
247- #
248- # In this case we clear the connection and try again.
249- pool_request .clear_connection ()
250244 except ConnectionGoingAway as exc :
251245 # GOAWAY frame recieved during request processing.
252246 # Determine if we can safely retry based on RFC 7540 semantics.
247+ # NOTE: This must be caught before ConnectionNotAvailable since
248+ # ConnectionGoingAway is a subclass of ConnectionNotAvailable.
253249 pool_request .clear_connection ()
254250
255251 if exc .is_safe_to_retry :
@@ -266,6 +262,12 @@ async def handle_async_request(self, request: Request) -> Response:
266262 msg = "GOAWAY recieved: request may have been processed"
267263 # QUESTION: What is the best way to propagate the context for the applications?
268264 raise RemoteProtocolError (msg ) from exc
265+ except ConnectionNotAvailable :
266+ # In some cases a connection may initially be available to
267+ # handle a request, but then become unavailable.
268+ #
269+ # In this case we clear the connection and try again.
270+ pool_request .clear_connection ()
269271 else :
270272 break # pragma: nocover
271273
0 commit comments