diff --git a/CHANGES.txt b/CHANGES.txt index 1baddf34..6c4ee8c8 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -1,8 +1,8 @@ Changes ------- -0.9.2a0 (2018-XX-XX) -^^^^^^^^^^^^^^^^^^^^ -* +0.9.2 (2018-05-05) +^^^^^^^^^^^^^^^^^^ +* bump aiohttp requirement to fix read timeouts 0.9.1 (2018-05-04) ^^^^^^^^^^^^^^^^^^ diff --git a/aiobotocore/__init__.py b/aiobotocore/__init__.py index c4fa2b34..47342cfa 100644 --- a/aiobotocore/__init__.py +++ b/aiobotocore/__init__.py @@ -1,4 +1,4 @@ from .session import get_session, AioSession __all__ = ['get_session', 'AioSession'] -__version__ = '0.9.2a0' +__version__ = '0.9.2' diff --git a/aiobotocore/endpoint.py b/aiobotocore/endpoint.py index 4de81a71..c1a89689 100644 --- a/aiobotocore/endpoint.py +++ b/aiobotocore/endpoint.py @@ -153,6 +153,9 @@ class ClientResponseProxy(wrapt.ObjectProxy): def __init__(self, *args, **kwargs): super().__init__(ClientResponse(*args, **kwargs)) + # this matches ClientResponse._body + self._self_body = None + @property def status_code(self): return self.status @@ -166,13 +169,16 @@ def status_code(self, value): @property def content(self): - # ClientResponse._body is set by the coroutine ClientResponse.read - return self._body + return self._self_body @property def raw(self): return ClientResponseContentProxy(self) + async def read(self): + self._self_body = await self.__wrapped__.read() + return self._self_body + class AioEndpoint(Endpoint): def __init__(self, host, diff --git a/requirements-dev.txt b/requirements-dev.txt index a371d238..f3fb51c8 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -13,7 +13,7 @@ pytest==3.4.1 pytest-asyncio==0.8.0 sphinx==1.7.1 yarl==1.1.1 -aiohttp==3.3.0 +aiohttp==3.3.1 botocore==1.10.12 boto3==1.7.12 multidict==4.1.0 diff --git a/setup.py b/setup.py index 7c7fbb37..609b0778 100644 --- a/setup.py +++ b/setup.py @@ -8,9 +8,7 @@ install_requires = [ # pegged to also match items in `extras_require` 'botocore>=1.10.12, <1.10.13', - - # NOTE: If behavior of ClientResponse._body changes we'll break - 'aiohttp>=3.3.0', + 'aiohttp>=3.3.1', 'wrapt>=1.10.10', ] diff --git a/tests/mock_server.py b/tests/mock_server.py index 2da98734..476ee725 100644 --- a/tests/mock_server.py +++ b/tests/mock_server.py @@ -4,7 +4,6 @@ from aiohttp.web import StreamResponse import pytest import requests -import shutil import signal import subprocess as sp import sys @@ -106,9 +105,8 @@ async def _wait_until_up(self): def start_service(service_name, host, port): - moto_svr_path = shutil.which("moto_server") - args = [sys.executable, moto_svr_path, service_name, "-H", host, - "-p", str(port)] + args = [sys.executable, "-m", "moto.server", "-H", host, + "-p", str(port), service_name] # If test fails stdout/stderr will be shown process = sp.Popen(args, stdin=sp.PIPE) diff --git a/tests/test_config.py b/tests/test_config.py index 52dd7915..efbd5fab 100644 --- a/tests/test_config.py +++ b/tests/test_config.py @@ -75,24 +75,18 @@ async def get_and_wait(): task2.cancel() -# Enable this once https://github.com/aio-libs/aiohttp/issues/3053 is fixed -# @pytest.mark.moto -# @pytest.mark.asyncio -# async def test_connector_timeout2(event_loop): -# session = AioSession(loop=event_loop) -# config = AioConfig(max_pool_connections=1, connect_timeout=1, -# read_timeout=1, retries={'max_attempts': 0}) -# async with AIOServer() as server, \ -# session.create_client('s3', config=config, -# endpoint_url=server.endpoint_url, -# aws_secret_access_key='xxx', -# aws_access_key_id='xxx') as s3_client: -# -# with pytest.raises(TimeoutError): -# try: -# resp = await s3_client.get_object(Bucket='foo', Key='bar') -# print() -# await resp["Body"].read() -# print() -# except BaseException as e: -# raise +@pytest.mark.moto +@pytest.mark.asyncio +async def test_connector_timeout2(event_loop): + session = AioSession(loop=event_loop) + config = AioConfig(max_pool_connections=1, connect_timeout=1, + read_timeout=1, retries={'max_attempts': 0}) + async with AIOServer() as server, \ + session.create_client('s3', config=config, + endpoint_url=server.endpoint_url, + aws_secret_access_key='xxx', + aws_access_key_id='xxx') as s3_client: + + with pytest.raises(asyncio.TimeoutError): + resp = await s3_client.get_object(Bucket='foo', Key='bar') + await resp["Body"].read()