Skip to content

Commit

Permalink
switch to new aiohttp release (#596)
Browse files Browse the repository at this point in the history
  • Loading branch information
thehesiod authored Jun 5, 2018
1 parent e15f844 commit 6af8d66
Show file tree
Hide file tree
Showing 7 changed files with 31 additions and 35 deletions.
6 changes: 3 additions & 3 deletions CHANGES.txt
Original file line number Diff line number Diff line change
@@ -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)
^^^^^^^^^^^^^^^^^^
Expand Down
2 changes: 1 addition & 1 deletion aiobotocore/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from .session import get_session, AioSession

__all__ = ['get_session', 'AioSession']
__version__ = '0.9.2a0'
__version__ = '0.9.2'
10 changes: 8 additions & 2 deletions aiobotocore/endpoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion requirements-dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 1 addition & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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',
]

Expand Down
6 changes: 2 additions & 4 deletions tests/mock_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
from aiohttp.web import StreamResponse
import pytest
import requests
import shutil
import signal
import subprocess as sp
import sys
Expand Down Expand Up @@ -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)
Expand Down
36 changes: 15 additions & 21 deletions tests/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()

0 comments on commit 6af8d66

Please sign in to comment.