Skip to content
Merged
Show file tree
Hide file tree
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: 9 additions & 3 deletions arangoasync/connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,11 +160,16 @@ def compress_request(self, request: Request) -> bool:

return result

async def process_request(self, request: Request) -> Response:
async def process_request(
self,
request: Request,
skip_db_prefix: bool = False,
) -> Response:
"""Process request, potentially trying multiple hosts.

Args:
request (Request): Request object.
skip_db_prefix (bool): If `True`, do not prepend the database endpoint.

Returns:
Response: Response object.
Expand All @@ -173,7 +178,8 @@ async def process_request(self, request: Request) -> Response:
ConnectionAbortedError: If it can't connect to host(s) within limit.
"""

request.endpoint = f"{self._db_endpoint}{request.endpoint}"
if not skip_db_prefix:
request.endpoint = f"{self._db_endpoint}{request.endpoint}"
host_index = self._host_resolver.get_host_index()
for tries in range(self._host_resolver.max_tries):
try:
Expand Down Expand Up @@ -376,7 +382,7 @@ async def refresh_token(self) -> None:
)

try:
resp = await self.process_request(request)
resp = await self.process_request(request, skip_db_prefix=True)
except ClientConnectionAbortedError as e:
raise JWTRefreshError(str(e)) from e
except ServerConnectionError as e:
Expand Down
6 changes: 6 additions & 0 deletions tests/test_connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,12 @@ async def test_JwtConnection_ping_success(
status_code = await connection1.ping()
assert status_code == 200

# Refresh the token
await connection3.refresh_token()
status_code = await connection1.ping()
assert status_code == 200
assert connection3.token != connection1.token


@pytest.mark.asyncio
async def test_JwtSuperuserConnection_ping_success(
Expand Down
Loading