Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use threading.TIMEOUT_MAX for timeout #472

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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