Skip to content

Commit 7a7f43f

Browse files
ciscornpquentin
authored andcommitted
Replace asyncio.Timeout with async_timeout.timeout (elastic#38)
1 parent 5f03cca commit 7a7f43f

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

elasticsearch_async/connection.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import aiohttp
44
from aiohttp.client_exceptions import ServerFingerprintMismatch
5+
import async_timeout
56

67
from elasticsearch.exceptions import ConnectionError, ConnectionTimeout, SSLError
78
from elasticsearch.connection import Connection
@@ -50,7 +51,7 @@ async def perform_request(self, method, url, params=None, body=None, timeout=Non
5051
start = self.loop.time()
5152
response = None
5253
try:
53-
with aiohttp.Timeout(timeout or self.timeout):
54+
async with async_timeout.timeout(timeout or self.timeout):
5455
response = yield from self.session.request(method, url, data=body)
5556
raw_data = yield from response.text()
5657
duration = self.loop.time() - start

setup.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212

1313
install_requires = [
1414
'aiohttp',
15+
'async_timeout',
1516
'elasticsearch>=5.0.0',
1617
]
1718

0 commit comments

Comments
 (0)