Skip to content

Commit

Permalink
Use a higher timeout for httpx client
Browse files Browse the repository at this point in the history
The default timeout of 5 seconds is sometimes not enough if
you are upserting a huge batch. So, I bumped the default
timeout values to something more relaxed.
  • Loading branch information
mdumandag committed Aug 28, 2024
1 parent 10a0fdf commit 8aca894
Showing 1 changed file with 16 additions and 5 deletions.
21 changes: 16 additions & 5 deletions upstash_vector/client.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
from httpx import Client, AsyncClient
from typing import Any
from os import environ
from typing import Any

import httpx

from upstash_vector.core.index_operations import IndexOperations, AsyncIndexOperations
from upstash_vector.http import (
execute_with_parameters,
execute_with_parameters_async,
generate_headers,
)
from upstash_vector.core.index_operations import IndexOperations, AsyncIndexOperations


class Index(IndexOperations):
Expand All @@ -32,7 +33,12 @@ def __init__(
self, url: str, token: str, retries: int = 3, retry_interval: float = 1.0
):
self._url = url
self._client = Client()
self._client = httpx.Client(
timeout=httpx.Timeout(
timeout=120.0,
connect=10.0,
)
)
self._retries = retries
self._retry_interval = retry_interval
self._headers = generate_headers(token)
Expand Down Expand Up @@ -89,7 +95,12 @@ def __init__(
):
self._url = url
self._headers = generate_headers(token)
self._client = AsyncClient()
self._client = httpx.AsyncClient(
timeout=httpx.Timeout(
timeout=120.0,
connect=10.0,
)
)
self._retries = retries
self._retry_interval = retry_interval

Expand Down

0 comments on commit 8aca894

Please sign in to comment.