Skip to content

Commit 86b4bb1

Browse files
ciscornpquentin
authored andcommitted
Replace asyncio.Timeout with async_timeout.timeout (elastic#38)
1 parent 761f605 commit 86b4bb1

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
@@ -51,7 +52,7 @@ def perform_request(self, method, url, params=None, body=None, timeout=None, ign
5152
start = self.loop.time()
5253
response = None
5354
try:
54-
with aiohttp.Timeout(timeout or self.timeout):
55+
async with async_timeout.timeout(timeout or self.timeout):
5556
response = yield from self.session.request(method, url, data=body)
5657
raw_data = yield from response.text()
5758
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)