diff --git a/setup.py b/setup.py index 057773a6e..97bd4876d 100755 --- a/setup.py +++ b/setup.py @@ -49,7 +49,7 @@ if sys.version_info > (3, 4, 2): async_require.append('aiohttp>=1.0') - tests_require.append('aioresponses>=0.1.3') + tests_require.append('aioresponses>=0.4.1') with open('README.rst') as fh: diff --git a/src/zeep/asyncio/transport.py b/src/zeep/asyncio/transport.py index 8990422e1..bdad20010 100644 --- a/src/zeep/asyncio/transport.py +++ b/src/zeep/asyncio/transport.py @@ -40,15 +40,14 @@ def __init__(self, loop, cache=None, timeout=300, operation_timeout=None, def __del__(self): if self._close_session: - self.session.close() + self.session.connector.close() def _load_remote_data(self, url): result = None async def _load_remote_data_async(): nonlocal result - with aiohttp.Timeout(self.load_timeout): - response = await self.session.get(url) + async with self.session.get(url, timeout=self.load_timeout) as response: result = await response.read() try: response.raise_for_status() @@ -65,9 +64,8 @@ async def _load_remote_data_async(): async def post(self, address, message, headers): self.logger.debug("HTTP Post to %s:\n%s", address, message) - with aiohttp.Timeout(self.operation_timeout): - response = await self.session.post( - address, data=message, headers=headers) + async with self.session.post(address, data=message, headers=headers, + timeout=self.operation_timeout) as response: self.logger.debug( "HTTP Response from %s (status: %d):\n%s", address, response.status, await response.read()) @@ -79,9 +77,8 @@ async def post_xml(self, address, envelope, headers): return await self.new_response(response) async def get(self, address, params, headers): - with aiohttp.Timeout(self.operation_timeout): - response = await self.session.get( - address, params=params, headers=headers) + async with self.session.get(address, params=params, headers=headers, + timeout=self.operation_timeout) as response: return await self.new_response(response) diff --git a/tox.ini b/tox.ini index 9b3d9e589..8f29ae1af 100644 --- a/tox.ini +++ b/tox.ini @@ -8,7 +8,7 @@ extras = xmlsec py{35,36}: async deps = - py{35,36}: aioresponses==0.1.3 + py{35,36}: aioresponses==0.4.1 py{35,36}: pytest-asyncio==0.5.0 commands = coverage run --parallel -m pytest {posargs}