Skip to content

Commit

Permalink
Fix usage of old aiohttp.Timeout import in Python 3.6
Browse files Browse the repository at this point in the history
  • Loading branch information
vdboor committed Apr 26, 2018
1 parent e4a12d8 commit e80c97e
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/zeep/asyncio/transport.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@
from zeep.utils import get_version
from zeep.wsdl.utils import etree_to_string

try:
from async_timeout import timeout as aio_timeout # Python 3.6+
except ImportError:
from aiohttp import Timeout as aio_timeout # Python 3.5, aiohttp < 3


__all__ = ['AsyncTransport']


Expand Down Expand Up @@ -47,7 +53,7 @@ def _load_remote_data(self, url):

async def _load_remote_data_async():
nonlocal result
with aiohttp.Timeout(self.load_timeout):
with aio_timeout(self.load_timeout):
response = await self.session.get(url)
result = await response.read()
try:
Expand All @@ -65,7 +71,7 @@ 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):
with aio_timeout(self.operation_timeout):
response = await self.session.post(
address, data=message, headers=headers)
self.logger.debug(
Expand Down

0 comments on commit e80c97e

Please sign in to comment.