Skip to content

Commit 8009c03

Browse files
authored
Merge pull request freqtrade#11117 from arenstar/ftclient_timeout
feat: add timeout to FtRestClient
2 parents a46d41a + ae068bd commit 8009c03

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

ft_client/freqtrade_client/ft_rest_client.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,18 @@
2323

2424
class FtRestClient:
2525
def __init__(
26-
self, serverurl, username=None, password=None, *, pool_connections=10, pool_maxsize=10
26+
self,
27+
serverurl,
28+
username=None,
29+
password=None,
30+
*,
31+
pool_connections=10,
32+
pool_maxsize=10,
33+
timeout=10,
2734
):
2835
self._serverurl = serverurl
2936
self._session = requests.Session()
37+
self._timeout = timeout
3038

3139
# allow configuration of pool
3240
adapter = HTTPAdapter(pool_connections=pool_connections, pool_maxsize=pool_maxsize)
@@ -50,7 +58,9 @@ def _call(self, method, apipath, params: dict | None = None, data=None, files=No
5058
url = urlunparse((schema, netloc, path, par, query, fragment))
5159

5260
try:
53-
resp = self._session.request(method, url, headers=hd, data=json.dumps(data))
61+
resp = self._session.request(
62+
method, url, headers=hd, timeout=self._timeout, data=json.dumps(data)
63+
)
5464
# return resp.text
5565
return resp.json()
5666
except RequestConnectionError:

0 commit comments

Comments
 (0)