Skip to content

Commit b28429a

Browse files
committed
add request_timeout
Signed-off-by: Praneeth Bedapudi <[email protected]>
1 parent f2e15f3 commit b28429a

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

clients/python/fdclient/client.py

+7-5
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,15 @@
1919

2020

2121
class FDClient:
22-
def __init__(self, server_url, compression=True):
23-
assert (
24-
server_url.startswith("http://") or server_url.startswith("https://")
22+
def __init__(self, server_url, compression=True, request_timeout=None):
23+
assert server_url.startswith("http://") or server_url.startswith(
24+
"https://"
2525
), "Server URL must start with http:// or https://"
2626

2727
assert (
2828
server_url.count("/") == 2
2929
), "Server URL must be in the format http(s)://<ip>:<port>"
30-
30+
3131
self.server_url = server_url
3232
self.local_storage = threading.local()
3333
self.requests_session = requests.Session()
@@ -41,6 +41,7 @@ def __init__(self, server_url, compression=True):
4141
if msgpack is not None
4242
else "json"
4343
)
44+
self.request_timeout = request_timeout
4445

4546
@property
4647
def _compressor(self):
@@ -109,6 +110,7 @@ def infer(self, data, unique_id=None, is_async=False):
109110
},
110111
data=self._compressor.compress(data) if zstandard is not None else data,
111112
headers={"Content-Type": "application/octet-stream"},
113+
timeout=self.request_timeout,
112114
)
113115

114116
if self.input_type == "pickle":
@@ -168,7 +170,7 @@ def __del__(self):
168170
print(
169171
"infer_background_multiple 40",
170172
[
171-
_.result()['success']
173+
_.result()["success"]
172174
for _ in client.infer_background_multiple(
173175
[["this", b"is", "some", "data"]] * 40
174176
)

clients/python/setup.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
1919
AUTHOR = "BEDAPUDI PRANEETH"
2020
REQUIRES_PYTHON = ">=3.6.0"
21-
VERSION = "3.0.2"
21+
VERSION = "3.0.3"
2222

2323
# What packages are required for this module to be executed?
2424
REQUIRED = ["zstandard", "requests", "msgpack"]

0 commit comments

Comments
 (0)