Skip to content

Commit a7ef11d

Browse files
committed
Corrections
1 parent 9a08221 commit a7ef11d

File tree

3 files changed

+25
-13
lines changed

3 files changed

+25
-13
lines changed

arango/client.py

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ class ArangoClient:
5555
:type verify_override: Union[bool, str, None]
5656
:param request_timeout: This is the default request timeout (in seconds)
5757
for http requests issued by the client if the parameter http_client is
58-
not secified. The default value is 60.
58+
not specified. The default value is 60.
5959
None: No timeout.
6060
int: Timeout value in seconds.
6161
:type request_timeout: Any
@@ -88,11 +88,7 @@ def __init__(
8888
self._host_resolver = RoundRobinHostResolver(host_count, resolver_max_tries)
8989

9090
# Initializes the http client
91-
self._http = http_client or DefaultHTTPClient()
92-
# Sets the request timeout.
93-
# This call can only happen AFTER initializing the http client.
94-
if http_client is None:
95-
self.request_timeout = request_timeout
91+
self._http = http_client or DefaultHTTPClient(request_timeout=request_timeout)
9692

9793
self._serializer = serializer
9894
self._deserializer = deserializer
@@ -137,12 +133,12 @@ def request_timeout(self) -> Any:
137133
:return: Request timeout.
138134
:rtype: Any
139135
"""
140-
return self._http.REQUEST_TIMEOUT # type: ignore
136+
return self._http.request_timeout # type: ignore
141137

142138
# Setter for request_timeout
143139
@request_timeout.setter
144140
def request_timeout(self, value: Any) -> None:
145-
self._http.REQUEST_TIMEOUT = value # type: ignore
141+
self._http.request_timeout = value # type: ignore
146142

147143
def db(
148144
self,

arango/http.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ class DefaultHTTPClient(HTTPClient):
117117
:param retry_attempts: Number of retry attempts.
118118
:type retry_attempts: int
119119
:param backoff_factor: Backoff factor for retry attempts.
120-
:type backoff_factor: int
120+
:type backoff_factor: float
121121
:param pool_connections: The number of urllib3 connection pools to cache.
122122
:type pool_connections: int
123123
:param pool_maxsize: The maximum number of connections to save in the pool.
@@ -130,12 +130,12 @@ def __init__(
130130
self,
131131
request_timeout: int = 60,
132132
retry_attempts: int = 3,
133-
backoff_factor: int = 1,
133+
backoff_factor: float = 1.0,
134134
pool_connections: int = 10,
135135
pool_maxsize: int = 10,
136136
pool_timeout: Union[int, float, None] = DEFAULT_POOL_TIMEOUT,
137137
) -> None:
138-
self._request_timeout = request_timeout
138+
self.request_timeout = request_timeout
139139
self._retry_attempts = retry_attempts
140140
self._backoff_factor = backoff_factor
141141
self._pool_connections = pool_connections
@@ -205,7 +205,7 @@ def send_request(
205205
data=data,
206206
headers=headers,
207207
auth=auth,
208-
timeout=self._request_timeout,
208+
timeout=self.request_timeout,
209209
)
210210
return Response(
211211
method=method,

tests/test_client.py

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ def test_client_attributes():
5454
assert isinstance(client._host_resolver, RandomHostResolver)
5555

5656
client = ArangoClient(hosts=client_hosts, request_timeout=120)
57-
assert client.request_timeout == client._http.REQUEST_TIMEOUT == 120
57+
assert client.request_timeout == client._http.request_timeout == 120
5858

5959

6060
def test_client_good_connection(db, username, password):
@@ -92,6 +92,22 @@ def test_client_bad_connection(db, username, password, cluster):
9292
assert "bad connection" in str(err.value)
9393

9494

95+
def test_client_http_client_attributes(db, username, password):
96+
http_client = DefaultHTTPClient(
97+
request_timeout=80,
98+
retry_attempts=5,
99+
backoff_factor=1.0,
100+
pool_connections=16,
101+
pool_maxsize=12,
102+
pool_timeout=120,
103+
)
104+
client = ArangoClient(
105+
hosts="http://127.0.0.1:8529", http_client=http_client, request_timeout=30
106+
)
107+
client.db(db.name, username, password, verify=True)
108+
assert http_client.request_timeout == 80
109+
110+
95111
def test_client_custom_http_client(db, username, password):
96112
# Define custom HTTP client which increments the counter on any API call.
97113
class MyHTTPClient(DefaultHTTPClient):

0 commit comments

Comments
 (0)