Skip to content

Commit

Permalink
add request_timeout
Browse files Browse the repository at this point in the history
Signed-off-by: Praneeth Bedapudi <praneeth@bpraneeth.com>
  • Loading branch information
bedapudi6788 committed Mar 18, 2024
1 parent f2e15f3 commit b28429a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
12 changes: 7 additions & 5 deletions clients/python/fdclient/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,15 @@


class FDClient:
def __init__(self, server_url, compression=True):
assert (
server_url.startswith("http://") or server_url.startswith("https://")
def __init__(self, server_url, compression=True, request_timeout=None):
assert server_url.startswith("http://") or server_url.startswith(
"https://"
), "Server URL must start with http:// or https://"

assert (
server_url.count("/") == 2
), "Server URL must be in the format http(s)://<ip>:<port>"

self.server_url = server_url
self.local_storage = threading.local()
self.requests_session = requests.Session()
Expand All @@ -41,6 +41,7 @@ def __init__(self, server_url, compression=True):
if msgpack is not None
else "json"
)
self.request_timeout = request_timeout

@property
def _compressor(self):
Expand Down Expand Up @@ -109,6 +110,7 @@ def infer(self, data, unique_id=None, is_async=False):
},
data=self._compressor.compress(data) if zstandard is not None else data,
headers={"Content-Type": "application/octet-stream"},
timeout=self.request_timeout,
)

if self.input_type == "pickle":
Expand Down Expand Up @@ -168,7 +170,7 @@ def __del__(self):
print(
"infer_background_multiple 40",
[
_.result()['success']
_.result()["success"]
for _ in client.infer_background_multiple(
[["this", b"is", "some", "data"]] * 40
)
Expand Down
2 changes: 1 addition & 1 deletion clients/python/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
EMAIL = "praneeth@bpraneeth.com"
AUTHOR = "BEDAPUDI PRANEETH"
REQUIRES_PYTHON = ">=3.6.0"
VERSION = "3.0.2"
VERSION = "3.0.3"

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

0 comments on commit b28429a

Please sign in to comment.