Add preference for non 404 responses fix test RC.

Fixed race condition with the 404 test.
This commit is contained in:
czaky 2024-05-17 12:55:00 +00:00
parent c302f113b0
commit 5fe7e42d1a
2 changed files with 22 additions and 3 deletions

View file

@ -222,6 +222,7 @@ class AsyncParallelTransport(httpx.AsyncBaseTransport):
self,
request: httpx.Request,
) -> httpx.Response:
# pylint: disable=too-many-branches
"""Issue parallel requests to all sub-transports.
Return the response of the first completed.
@ -254,7 +255,9 @@ class AsyncParallelTransport(httpx.AsyncBaseTransport):
for task in done:
try:
result = task.result()
if not result.is_error or result.status_code == 404:
if not result.is_error:
response = result
elif result.status_code == 404 and response is None:
response = result
elif not error_response:
self._logger.warning("Error response: %s for %s", result.status_code, request.url)