Skip to content

Commit

Permalink
[python{,-experimental}] Obey floating point timeouts provided to RES…
Browse files Browse the repository at this point in the history
…TClientObject.request(...) (#7154)

* [fix] support floating point timeout durations

* [lint] generate samples, rebuild project
  • Loading branch information
cjgibson authored Aug 10, 2020
1 parent 1ee57ea commit d37216a
Show file tree
Hide file tree
Showing 8 changed files with 8 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ class RESTClientObject(object):

timeout = None
if _request_timeout:
if isinstance(_request_timeout, int): # noqa: E501,F821
if isinstance(_request_timeout, (int, float)): # noqa: E501,F821
timeout = urllib3.Timeout(total=_request_timeout)
elif (isinstance(_request_timeout, tuple) and
len(_request_timeout) == 2):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ class RESTClientObject(object):

timeout = None
if _request_timeout:
if isinstance(_request_timeout, (int, ) if six.PY3 else (int, long)): # noqa: E501,F821
if isinstance(_request_timeout, six.integer_types + (float, )): # noqa: E501,F821
timeout = urllib3.Timeout(total=_request_timeout)
elif (isinstance(_request_timeout, tuple) and
len(_request_timeout) == 2):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ def request(self, method, url, query_params=None, headers=None,

timeout = None
if _request_timeout:
if isinstance(_request_timeout, int): # noqa: E501,F821
if isinstance(_request_timeout, (int, float)): # noqa: E501,F821
timeout = urllib3.Timeout(total=_request_timeout)
elif (isinstance(_request_timeout, tuple) and
len(_request_timeout) == 2):
Expand Down
2 changes: 1 addition & 1 deletion samples/client/petstore/python/petstore_api/rest.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ def request(self, method, url, query_params=None, headers=None,

timeout = None
if _request_timeout:
if isinstance(_request_timeout, (int, ) if six.PY3 else (int, long)): # noqa: E501,F821
if isinstance(_request_timeout, six.integer_types + (float, )): # noqa: E501,F821
timeout = urllib3.Timeout(total=_request_timeout)
elif (isinstance(_request_timeout, tuple) and
len(_request_timeout) == 2):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ def request(self, method, url, query_params=None, headers=None,

timeout = None
if _request_timeout:
if isinstance(_request_timeout, int): # noqa: E501,F821
if isinstance(_request_timeout, (int, float)): # noqa: E501,F821
timeout = urllib3.Timeout(total=_request_timeout)
elif (isinstance(_request_timeout, tuple) and
len(_request_timeout) == 2):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ def request(self, method, url, query_params=None, headers=None,

timeout = None
if _request_timeout:
if isinstance(_request_timeout, int): # noqa: E501,F821
if isinstance(_request_timeout, (int, float)): # noqa: E501,F821
timeout = urllib3.Timeout(total=_request_timeout)
elif (isinstance(_request_timeout, tuple) and
len(_request_timeout) == 2):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ def request(self, method, url, query_params=None, headers=None,

timeout = None
if _request_timeout:
if isinstance(_request_timeout, int): # noqa: E501,F821
if isinstance(_request_timeout, (int, float)): # noqa: E501,F821
timeout = urllib3.Timeout(total=_request_timeout)
elif (isinstance(_request_timeout, tuple) and
len(_request_timeout) == 2):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ def request(self, method, url, query_params=None, headers=None,

timeout = None
if _request_timeout:
if isinstance(_request_timeout, (int, ) if six.PY3 else (int, long)): # noqa: E501,F821
if isinstance(_request_timeout, six.integer_types + (float, )): # noqa: E501,F821
timeout = urllib3.Timeout(total=_request_timeout)
elif (isinstance(_request_timeout, tuple) and
len(_request_timeout) == 2):
Expand Down

0 comments on commit d37216a

Please sign in to comment.