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

Cannot set both keepalive_timeout to None and force_close to True #932

Closed
6 tasks done
dnlserrano opened this issue May 3, 2022 · 0 comments · Fixed by #935
Closed
6 tasks done

Cannot set both keepalive_timeout to None and force_close to True #932

dnlserrano opened this issue May 3, 2022 · 0 comments · Fixed by #935

Comments

@dnlserrano
Copy link

Describe the bug
Cannot set both keepalive_timeout to None and force_close to True in AioConfig.

This fails:

from aiobotocore import config
aioconfig = config.AioConfig(connector_args={'keepalive_timeout': None, 'force_close': True})
...
File ~/Repos/aiobotocore/aiobotocore/config.py:42, in AioConfig._validate_connector_args(connector_args)
     40 elif k in ['keepalive_timeout']:
     41     if not isinstance(v, (float, int)):
---> 42         raise ParamValidationError(
     43             report='{} value must be a float/int'.format(k))
     44 elif k == 'force_close':
     45     if not isinstance(v, bool):

ParamValidationError: Parameter validation failed:
keepalive_timeout value must be a float/int

But then the following also fails because aiohttp requires keepalive_timeout to be None when force_close is True:

from aiobotocore.session import get_session
from aiobotocore import config

aioconfig = config.AioConfig(connector_args={'keepalive_timeout': 12, 'force_close': True})

session = get_session()
async with session.create_client("s3", config=aioconfig) as client:
  await client.head_bucket(Bucket="mybucket")
...
File ~/.local/share/virtualenvs/aiobotocore-ab5i-gBl/lib/python3.10/site-packages/aiohttp/connector.py:219, in BaseConnector.__init__(self, keepalive_timeout, force_close, limit, limit_per_host, enable_cleanup_closed, loop)
    217 if force_close:
    218     if keepalive_timeout is not None and keepalive_timeout is not sentinel:
--> 219         raise ValueError(
    220             "keepalive_timeout cannot " "be set if force_close is True"
    221         )
    222 else:
    223     if keepalive_timeout is sentinel:

ValueError: keepalive_timeout cannot be set if force_close is True

Checklist

  • I have reproduced in environment where pip check passes without errors
  • I have provided pip freeze results
  • I have provided sample code or detailed way to reproduce
  • I have tried the same code in botocore to ensure this is an aiobotocore specific issue
  • I have tried similar code in aiohttp to ensure this is is an aiobotocore specific issue
  • I have checked the latest and older versions of aiobotocore/aiohttp/python to see if this is a regression / injection

pip freeze results

aiohttp==3.8.1
aioitertools==0.10.0
aiosignal==1.2.0
appnope==0.1.3
asttokens==2.0.5
async-timeout==4.0.2
attrs==21.4.0
backcall==0.2.0
black==22.3.0
botocore==1.24.21
certifi==2021.10.8
charset-normalizer==2.0.12
click==8.1.3
cmake==3.22.3
decorator==5.1.1
dface==1.1.5
distlib==0.3.4
distro==1.7.0
executing==0.8.3
filelock==3.6.0
frozenlist==1.3.0
idna==3.3
ipython==8.2.0
jedi==0.18.1
jmespath==1.0.0
joblib==1.1.0
matplotlib-inline==0.1.3
multidict==6.0.2
mypy-extensions==0.4.3
numpy==1.22.3
opencv-python==4.5.5.64
packaging==21.3
parso==0.8.3
pathspec==0.9.0
pexpect==4.8.0
pickleshare==0.7.5
Pillow==9.1.0
pipenv==2022.5.2
platformdirs==2.5.2
prompt-toolkit==3.0.29
ptyprocess==0.7.0
pure-eval==0.2.2
Pygments==2.11.2
pyparsing==3.0.7
python-dateutil==2.8.2
requests==2.27.1
scikit-build==0.13.1
scikit-learn==1.0.2
scipy==1.8.0
six==1.16.0
sklearn==0.0
stack-data==0.2.0
threadpoolctl==3.1.0
timm==0.5.4
toml==0.10.2
tomli==2.0.1
torch==1.11.0
torchvision==0.12.0
tqdm==4.64.0
traitlets==5.1.1
typing_extensions==4.2.0
urllib3==1.26.9
virtualenv==20.14.1
virtualenv-clone==0.5.7
wcwidth==0.2.5
wrapt==1.14.1
yarl==1.7.2

Environment:

  • Python Version: 3.10.4
  • OS name and version: macOS Monterey 12.3.1

Additional context
None.

dnlserrano added a commit to dnlserrano/aiobotocore that referenced this issue May 3, 2022
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
@thehesiod thehesiod linked a pull request May 6, 2022 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant