Skip to content

Commit 19c6ecb

Browse files
committed
Fix compatibility with aiohttp>=3
aiohttp.Timeout is no longer available
1 parent e4a12d8 commit 19c6ecb

File tree

2 files changed

+7
-10
lines changed

2 files changed

+7
-10
lines changed

setup.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@
4949

5050
if sys.version_info > (3, 4, 2):
5151
async_require.append('aiohttp>=1.0')
52-
tests_require.append('aioresponses>=0.1.3')
52+
tests_require.append('aioresponses>=0.4.1')
5353

5454

5555
with open('README.rst') as fh:

src/zeep/asyncio/transport.py

+6-9
Original file line numberDiff line numberDiff line change
@@ -40,15 +40,14 @@ def __init__(self, loop, cache=None, timeout=300, operation_timeout=None,
4040

4141
def __del__(self):
4242
if self._close_session:
43-
self.session.close()
43+
self.session.connector.close()
4444

4545
def _load_remote_data(self, url):
4646
result = None
4747

4848
async def _load_remote_data_async():
4949
nonlocal result
50-
with aiohttp.Timeout(self.load_timeout):
51-
response = await self.session.get(url)
50+
async with self.session.get(url, timeout=self.load_timeout) as response:
5251
result = await response.read()
5352
try:
5453
response.raise_for_status()
@@ -65,9 +64,8 @@ async def _load_remote_data_async():
6564

6665
async def post(self, address, message, headers):
6766
self.logger.debug("HTTP Post to %s:\n%s", address, message)
68-
with aiohttp.Timeout(self.operation_timeout):
69-
response = await self.session.post(
70-
address, data=message, headers=headers)
67+
async with self.session.post(address, data=message, headers=headers,
68+
timeout=self.operation_timeout) as response:
7169
self.logger.debug(
7270
"HTTP Response from %s (status: %d):\n%s",
7371
address, response.status, await response.read())
@@ -79,9 +77,8 @@ async def post_xml(self, address, envelope, headers):
7977
return await self.new_response(response)
8078

8179
async def get(self, address, params, headers):
82-
with aiohttp.Timeout(self.operation_timeout):
83-
response = await self.session.get(
84-
address, params=params, headers=headers)
80+
async with self.session.get(address, params=params, headers=headers,
81+
timeout=self.operation_timeout) as response:
8582

8683
return await self.new_response(response)
8784

0 commit comments

Comments
 (0)