remove timeouts on ES connection

pull/413/head
simon 1 year ago
parent 89ac53083f
commit c0e36133a1
No known key found for this signature in database
GPG Key ID: 2C15AA5E89985DD4

@ -3,6 +3,7 @@ functionality:
- wrapper around requests to call elastic search - wrapper around requests to call elastic search
- reusable search_after to extract total index - reusable search_after to extract total index
""" """
# pylint: disable=missing-timeout
import json import json
@ -55,16 +56,10 @@ class ElasticWrap:
if data: if data:
response = requests.post( response = requests.post(
self.url, self.url, data=payload, headers=headers, auth=self.auth
data=payload,
headers=headers,
auth=self.auth,
timeout=10,
) )
else: else:
response = requests.post( response = requests.post(self.url, headers=headers, auth=self.auth)
self.url, headers=headers, auth=self.auth, timeout=10
)
if not response.ok: if not response.ok:
print(response.text) print(response.text)
@ -75,9 +70,7 @@ class ElasticWrap:
"""put data to es""" """put data to es"""
if refresh: if refresh:
self.url = f"{self.url}/?refresh=true" self.url = f"{self.url}/?refresh=true"
response = requests.put( response = requests.put(f"{self.url}", json=data, auth=self.auth)
f"{self.url}", json=data, auth=self.auth, timeout=10
)
if not response.ok: if not response.ok:
print(response.text) print(response.text)
print(data) print(data)
@ -90,11 +83,9 @@ class ElasticWrap:
if refresh: if refresh:
self.url = f"{self.url}/?refresh=true" self.url = f"{self.url}/?refresh=true"
if data: if data:
response = requests.delete( response = requests.delete(self.url, json=data, auth=self.auth)
self.url, json=data, auth=self.auth, timeout=10
)
else: else:
response = requests.delete(self.url, auth=self.auth, timeout=10) response = requests.delete(self.url, auth=self.auth)
if not response.ok: if not response.ok:
print(response.text) print(response.text)

Loading…
Cancel
Save