Skip to content

Commit

Permalink
Allow keepalive_timeout to be None
Browse files Browse the repository at this point in the history
There was a bug in the library in that we could not both:

  * set keepalive_timeout as None
  * set force_close to True

Validation was wrong in that it expects `keepalive_timeout` to have to be
one of `float` or `int`, but it should also allow `None` since `aiohttp`
requires `keepalive_timeout` to be `None` if `force_close` is set to
`True`.

Closes aio-libs#932
  • Loading branch information
dnlserrano committed May 3, 2022
1 parent 4694ba4 commit 45c6140
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
4 changes: 2 additions & 2 deletions aiobotocore/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@ def _validate_connector_args(connector_args):
raise ParamValidationError(
report='{} value must be a boolean'.format(k))
elif k in ['keepalive_timeout']:
if not isinstance(v, (float, int)):
if v is not None and not isinstance(v, (float, int)):
raise ParamValidationError(
report='{} value must be a float/int'.format(k))
report='{} value must be a float/int or None'.format(k))
elif k == 'force_close':
if not isinstance(v, bool):
raise ParamValidationError(
Expand Down
8 changes: 7 additions & 1 deletion tests/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,11 @@ def test_connector_args():
connector_args = dict(force_close="1")
AioConfig(connector_args)

with pytest.raises(ParamValidationError):
# wrong type
connector_args = dict(keepalive_timeout="1")
AioConfig(connector_args)

with pytest.raises(ParamValidationError):
# wrong type
connector_args = dict(ssl_context="1")
Expand All @@ -43,10 +48,11 @@ def test_connector_args():
connector_args = dict(foo="1")
AioConfig(connector_args)

# Test valid config:
# Test valid configs:
AioConfig({
"resolver": aiohttp.resolver.DefaultResolver()
})
AioConfig({'keepalive_timeout': None})

# test merge
cfg = Config(read_timeout=75)
Expand Down

0 comments on commit 45c6140

Please sign in to comment.