support timeout customization

This commit is contained in:
Damien Elmes 2018-09-19 23:47:54 +10:00
parent 26ffd619a6
commit 8f05db5981

View File

@ -426,6 +426,7 @@ from notes where %s""" % d)
class AnkiRequestsClient: class AnkiRequestsClient:
verify = True verify = True
timeout = 60
def __init__(self): def __init__(self):
self.session = requests.Session() self.session = requests.Session()
@ -434,13 +435,13 @@ class AnkiRequestsClient:
data = _MonitoringFile(data) data = _MonitoringFile(data)
headers['User-Agent'] = self._agentName() headers['User-Agent'] = self._agentName()
return self.session.post( return self.session.post(
url, data=data, headers=headers, stream=True, timeout=60, verify=self.verify) url, data=data, headers=headers, stream=True, timeout=self.timeout, verify=self.verify)
def get(self, url, headers=None): def get(self, url, headers=None):
if headers is None: if headers is None:
headers = {} headers = {}
headers['User-Agent'] = self._agentName() headers['User-Agent'] = self._agentName()
return self.session.get(url, stream=True, headers=headers, timeout=60, verify=self.verify) return self.session.get(url, stream=True, headers=headers, timeout=self.timeout, verify=self.verify)
def streamContent(self, resp): def streamContent(self, resp):
resp.raise_for_status() resp.raise_for_status()