Skip to content

Fix compatability with aiohttp>=3 #713

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

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
15 changes: 6 additions & 9 deletions src/zeep/asyncio/transport.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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())
Expand All @@ -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)

Expand Down
2 changes: 1 addition & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -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}

Expand Down