wmt-2020-pl-en/googletrans/adapters.py
Mateusz Susik 004f40ceb8 feat(adapters): print statement removal (#53)
* adapters: print statement removal

Signed-off-by: Mateusz Susik <mateusz.susik@sigmoidal.io>

* test fix - read timeout added

Signed-off-by: Mateusz Susik <mateusz.susik@sigmoidal.io>
2018-05-06 21:17:21 +09:00

17 lines
562 B
Python

from requests.adapters import HTTPAdapter
class TimeoutAdapter(HTTPAdapter):
"""HTTP adapter that adds timeout to each query."""
def __init__(self, timeout=None, *args, **kwargs):
"""HTTP adapter that adds timeout to each query.
:param timeout: Timeout that will be added to each query
"""
self.timeout = timeout
super(TimeoutAdapter, self).__init__(*args, **kwargs)
def send(self, *args, **kwargs):
kwargs['timeout'] = self.timeout
return super(TimeoutAdapter, self).send(*args, **kwargs)