Skip to content
Open
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
2 changes: 2 additions & 0 deletions qdrant_client/http/api_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,8 @@ async def request( # noqa F811
# in order to do a correct join, url join requires base_url to end with /, and url to not start with /,
# since url is treated as an absolute path and might truncate prefix in base_url
url = urljoin(host, url.format(**path_params))
if "params" in kwargs and "timeout" in kwargs["params"]:
kwargs["timeout"] = int(kwargs["params"]["timeout"])
request = self._async_client.build_request(method, url, **kwargs)
return await self.send(request, type_)

Expand Down
30 changes: 30 additions & 0 deletions tests/test_qdrant_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
from pprint import pprint
from tempfile import mkdtemp
from time import sleep
from unittest.mock import patch

import numpy as np
import pytest
Expand Down Expand Up @@ -1757,6 +1758,35 @@ def test_timeout_propagation():
)


def test_async_rest_timeout_propagation():
# Regression for #1325: async client dropped the per-call `timeout=`
# from kwargs before build_request, leaving callers bound by httpx's
# default 5s timeout. Sync ApiClient.request already promotes it.
from qdrant_client.http.api_client import AsyncApiClient
from unittest.mock import AsyncMock

captured: dict = {}

def _capture(method, url, **kwargs):
captured["kwargs"] = kwargs
return type("DummyRequest", (), {"headers": {}})()

async_client = AsyncApiClient(host="http://localhost:6333")
with patch.object(async_client._async_client, "build_request", _capture), \
patch.object(async_client, "send", new=AsyncMock()):
asyncio.run(
async_client.request(
type_=None,
method="GET",
url="/collections/{c}",
path_params={"c": "x"},
params={"timeout": "50"},
)
)

assert captured["kwargs"].get("timeout") == 50


def test_grpc_options():
client_version = importlib.metadata.version("qdrant-client")
user_agent = f"python-client/{client_version}"
Expand Down