diff --git a/qdrant_client/qdrant_client.py b/qdrant_client/qdrant_client.py index 342ac5e1..91d5651b 100644 --- a/qdrant_client/qdrant_client.py +++ b/qdrant_client/qdrant_client.py @@ -3,6 +3,7 @@ from multiprocessing import get_all_start_methods from typing import Optional, Iterable, List, Union, Tuple, Type +import httpx import numpy as np from loguru import logger @@ -66,6 +67,13 @@ def __init__(self, self._https = https self._api_key = api_key + limits = kwargs.pop('limits', None) + if limits is None: + if self._host in ['localhost', '127.0.0.1']: + # Disable keep-alive for local connections + # Cause in some cases, it may cause extra delays + limits = httpx.Limits(max_connections=None, max_keepalive_connections=0) + http2 = kwargs.pop("http2", False) self._grpc_headers = {} self._rest_headers = kwargs.pop("headers", {}) @@ -87,6 +95,9 @@ def __init__(self, **kwargs } + if limits is not None: + self._rest_args['limits'] = limits + self.openapi_client = SyncApis(host=self.rest_uri, **self._rest_args) self._grpc_channel = None