Skip to content

Commit c9deb3e

Browse files
authored
disable keep-alive for local connections (#69)
* disable keep-alive for local connections * fix tests * fix tests
1 parent d0a45c3 commit c9deb3e

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

qdrant_client/qdrant_client.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
from multiprocessing import get_all_start_methods
44
from typing import Optional, Iterable, List, Union, Tuple, Type
55

6+
import httpx
67
import numpy as np
78
from loguru import logger
89

@@ -66,6 +67,13 @@ def __init__(self,
6667
self._https = https
6768
self._api_key = api_key
6869

70+
limits = kwargs.pop('limits', None)
71+
if limits is None:
72+
if self._host in ['localhost', '127.0.0.1']:
73+
# Disable keep-alive for local connections
74+
# Cause in some cases, it may cause extra delays
75+
limits = httpx.Limits(max_connections=None, max_keepalive_connections=0)
76+
6977
http2 = kwargs.pop("http2", False)
7078
self._grpc_headers = {}
7179
self._rest_headers = kwargs.pop("headers", {})
@@ -87,6 +95,9 @@ def __init__(self,
8795
**kwargs
8896
}
8997

98+
if limits is not None:
99+
self._rest_args['limits'] = limits
100+
90101
self.openapi_client = SyncApis(host=self.rest_uri, **self._rest_args)
91102

92103
self._grpc_channel = None

0 commit comments

Comments
 (0)