Skip to content

Commit

Permalink
Implement support for connect timeouts, aiohttp minimum version is no…
Browse files Browse the repository at this point in the history
…w 3.3
  • Loading branch information
sjaensch committed Jan 9, 2019
1 parent 80c4234 commit dd2409e
Showing 1 changed file with 7 additions and 13 deletions.
20 changes: 7 additions & 13 deletions bravado_asyncio/http_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
import logging
import ssl
from collections import Mapping
from distutils.version import LooseVersion
from typing import Any
from typing import Callable # noqa: F401
from typing import cast
Expand Down Expand Up @@ -158,9 +157,10 @@ def request(

params = self.prepare_params(request_params.get('params'))

connect_timeout = request_params.get('connect_timeout')
request_timeout = request_params.get('timeout')
timeout = aiohttp.ClientTimeout(
connect_timeout = request_params.get('connect_timeout') # type: Optional[float]
request_timeout = request_params.get('timeout') # type: Optional[float]
# mypy thinks the type of total and connect is float, even though it is Optional[float]. Let's ignore the error.
timeout = aiohttp.ClientTimeout( # type: ignore
total=request_timeout,
connect=connect_timeout,
) if (connect_timeout or request_timeout) else None
Expand Down Expand Up @@ -204,12 +204,6 @@ def prepare_params(self, params: Optional[Dict[str, Any]]) -> Union[Optional[Dic
return MultiDict(items)

def _get_ssl_params(self) -> Dict[str, Any]:
aiohttp_version = LooseVersion(aiohttp.__version__)
if aiohttp_version < LooseVersion('3'):
if (self.ssl_verify is not None) or (self.ssl_context is not None):
log.warning('SSL options are not supported and will be ignored for aiohttp versions below 3.')
return {}
else:
return {
'ssl': self.ssl_context if self.ssl_context else self.ssl_verify
}
return {
'ssl': self.ssl_context if self.ssl_context else self.ssl_verify
}

0 comments on commit dd2409e

Please sign in to comment.