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: 1 addition & 1 deletion qdrant_client/http/api_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ def request_sync(self, *, type_: Any, **kwargs: Any) -> Any: # noqa F811
"""
This method is not used by the generated apis, but is included for convenience
"""
return get_event_loop().run_until_complete(self.request(type_=type_, **kwargs))
return self.request(type_=type_, **kwargs)

def send(self, request: Request, type_: Type[T]) -> T:
response = self.middleware(request, self.send_inner)
Expand Down
28 changes: 28 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,33 @@ def test_timeout_propagation():
)


def test_api_client_request_sync_returns_value():
# Regression for #1336: sync client wrapped the return value in
# run_until_complete, so any non-awaitable result raised TypeError.
from qdrant_client.http.api_client import ApiClient

sync_client = ApiClient("http://localhost:6333")
with patch.object(sync_client, "request", return_value={"ok": True}) as mocked:
result = sync_client.request_sync(
type_=dict,
method="GET",
url="/collections",
)

assert result == {"ok": True}
mocked.assert_called_once_with(type_=dict, method="GET", url="/collections")

with patch.object(sync_client, "request", return_value=None) as mocked_none:
result_none = sync_client.request_sync(
type_=None,
method="GET",
url="/collections",
)

assert result_none is None
mocked_none.assert_called_once_with(type_=None, method="GET", url="/collections")


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