Skip to content

Commit

Permalink
use threading.TIMEOUT_MAX for timeout
Browse files Browse the repository at this point in the history
  • Loading branch information
tschaume committed Mar 18, 2021
1 parent 1d5e37f commit cbcb3bc
Showing 1 changed file with 8 additions and 10 deletions.
18 changes: 8 additions & 10 deletions bravado/http_future.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
from bravado_core.unmarshal import unmarshal_schema_object
from bravado_core.validate import validate_schema_object
from msgpack import unpackb
from threading import TIMEOUT_MAX

from bravado.config import bravado_config_from_config_dict
from bravado.config import BravadoConfig
Expand Down Expand Up @@ -90,13 +91,12 @@ def _raise_connection_error(self, exception):
# type: (BaseException) -> typing.NoReturn
self._raise_error(BravadoConnectionError, 'ConnectionError', exception)

def result(self, timeout=None):
def result(self, timeout=TIMEOUT_MAX):
# type: (typing.Optional[float]) -> T
"""
Must implement a result method which blocks on result retrieval.
:param timeout: maximum time to wait on result retrieval. Defaults to
None which means blocking undefinitely.
:param timeout: maximum time to wait on result retrieval.
"""
raise NotImplementedError(
"FutureAdapter must implement 'result' method"
Expand Down Expand Up @@ -170,15 +170,14 @@ def _bravado_config(self):

def response(
self,
timeout=None, # type: typing.Optional[float]
timeout=TIMEOUT_MAX, # type: typing.Optional[float]
fallback_result=SENTINEL, # type: typing.Union[_SENTINEL, T, typing.Callable[[BaseException], T]] # noqa
exceptions_to_catch=FALLBACK_EXCEPTIONS, # type: typing.Tuple[typing.Type[BaseException], ...]
):
# type: (...) -> BravadoResponse[T]
"""Blocking call to wait for the HTTP response.
:param timeout: Number of seconds to wait for a response. Defaults to
None which means wait indefinitely.
:param timeout: Number of seconds to wait for a response.
:type timeout: float
:param fallback_result: either the swagger result or a callable that accepts an exception as argument
and returns the swagger result to use in case of errors
Expand Down Expand Up @@ -254,15 +253,14 @@ def response(

def result(
self,
timeout=None, # type: typing.Optional[float]
timeout=TIMEOUT_MAX, # type: typing.Optional[float]
):
# type: (...) -> typing.Union[T, IncomingResponse, typing.Tuple[T, IncomingResponse]]
"""DEPRECATED: please use the `response()` method instead.
Blocking call to wait for and return the unmarshalled swagger result.
:param timeout: Number of seconds to wait for a response. Defaults to
None which means wait indefinitely.
:param timeout: Number of seconds to wait for a response.
:type timeout: float
:return: Depends on the value of also_return_response sent in
to the constructor.
Expand All @@ -286,7 +284,7 @@ def cancel(self):
return self.future.cancel()

@reraise_errors
def _get_incoming_response(self, timeout=None):
def _get_incoming_response(self, timeout=TIMEOUT_MAX):
# type: (typing.Optional[float]) -> IncomingResponse
inner_response = self.future.result(timeout=timeout)
incoming_response = self.response_adapter(inner_response)
Expand Down

0 comments on commit cbcb3bc

Please sign in to comment.