Shaman: added some timeouts to HTTP requests
This commit is contained in:
parent
c2a8ff18f8
commit
44ee553c0a
@ -55,7 +55,9 @@ class ShamanPacker(bat_pack.Packer):
|
|||||||
def _get_auth_token(self) -> str:
|
def _get_auth_token(self) -> str:
|
||||||
# TODO: get a token from the Flamenco Server.
|
# TODO: get a token from the Flamenco Server.
|
||||||
log.warning('Using temporary hack to get auth token from Shaman')
|
log.warning('Using temporary hack to get auth token from Shaman')
|
||||||
resp = requests.get(urllib.parse.urljoin(self.shaman_endpoint, 'get-token'))
|
resp = requests.get(urllib.parse.urljoin(self.shaman_endpoint, 'get-token'),
|
||||||
|
timeout=10)
|
||||||
|
resp.raise_for_status()
|
||||||
return resp.text
|
return resp.text
|
||||||
|
|
||||||
def _create_file_transferer(self) -> bat_transfer.FileTransferer:
|
def _create_file_transferer(self) -> bat_transfer.FileTransferer:
|
||||||
|
|||||||
@ -37,6 +37,7 @@ class ShamanClient:
|
|||||||
self._session.headers['Authorization'] = 'Bearer ' + auth_token
|
self._session.headers['Authorization'] = 'Bearer ' + auth_token
|
||||||
|
|
||||||
def request(self, method: str, url: str, **kwargs) -> requests.Response:
|
def request(self, method: str, url: str, **kwargs) -> requests.Response:
|
||||||
|
kwargs.setdefault('timeout', 300)
|
||||||
full_url = urllib.parse.urljoin(self._base_url, url)
|
full_url = urllib.parse.urljoin(self._base_url, url)
|
||||||
return self._session.request(method, full_url, **kwargs)
|
return self._session.request(method, full_url, **kwargs)
|
||||||
|
|
||||||
|
|||||||
@ -189,7 +189,8 @@ class ShamanTransferrer(bat_transfer.FileTransferer):
|
|||||||
need to be uploaded, or None if there was an error.
|
need to be uploaded, or None if there was an error.
|
||||||
"""
|
"""
|
||||||
resp = self.client.post('checkout/requirements', data=definition_file, stream=True,
|
resp = self.client.post('checkout/requirements', data=definition_file, stream=True,
|
||||||
headers={'Content-Type': 'text/plain'})
|
headers={'Content-Type': 'text/plain'},
|
||||||
|
timeout=15)
|
||||||
if resp.status_code >= 300:
|
if resp.status_code >= 300:
|
||||||
msg = 'Error from Shaman, code %d: %s' % (resp.status_code, resp.text)
|
msg = 'Error from Shaman, code %d: %s' % (resp.status_code, resp.text)
|
||||||
self.log.error(msg)
|
self.log.error(msg)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user