Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore, rapu: handle asyncio.TimeoutError #903

Merged
merged 1 commit into from
Jul 1, 2024
Merged
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
12 changes: 5 additions & 7 deletions karapace/rapu.py
Original file line number Diff line number Diff line change
Expand Up @@ -393,14 +393,12 @@ async def _handle_request(
)
headers = {"Content-Type": "application/json"}
resp = aiohttp.web.Response(body=body, status=status.value, headers=headers)
except (ConnectionError, aiohttp.ClientError) as connection_error:
# TCP level connection errors, e.g. TCP reset, client closes connection.
self.log.debug("Connection error.", exc_info=connection_error)
except (ConnectionError, aiohttp.ClientError, asyncio.CancelledError, asyncio.TimeoutError) as exc:
nosahama marked this conversation as resolved.
Show resolved Hide resolved
# TCP level connection errors and timeouts, e.g. TCP reset, client closes connection, task takes too long.
error_msg = "Unexpected connection or timeout error"
self.log.debug(error_msg, exc_info=exc)
nosahama marked this conversation as resolved.
Show resolved Hide resolved
# No response can be returned and written to client, aiohttp expects some response here.
resp = aiohttp.web.Response(text="Connection error", status=HTTPStatus.SERVICE_UNAVAILABLE.value)
except asyncio.CancelledError:
nosahama marked this conversation as resolved.
Show resolved Hide resolved
self.log.debug("Client closed connection")
raise
resp = aiohttp.web.Response(text=error_msg, status=HTTPStatus.SERVICE_UNAVAILABLE.value)
except Exception as ex: # pylint: disable=broad-except
self.stats.unexpected_exception(ex=ex, where="rapu_wrapped_callback")
self.log.exception("Unexpected error handling user request: %s %s", request.method, request.url)
Expand Down
Loading