Skip to content

Commit

Permalink
disable keep-alive for local connections (#69)
Browse files Browse the repository at this point in the history
* disable keep-alive for local connections

* fix tests

* fix tests
  • Loading branch information
generall authored Sep 5, 2022
1 parent d0a45c3 commit c9deb3e
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions qdrant_client/qdrant_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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", {})
Expand All @@ -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
Expand Down

0 comments on commit c9deb3e

Please sign in to comment.