Add explicit 3 second timeout to requests
This commit is contained in:
parent
39fd85fcc3
commit
e9dea4d2d1
|
@ -124,6 +124,9 @@ def call_api(config, operation, request_uri, headers={}, params=None, data=None,
|
||||||
request_uri
|
request_uri
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# Default timeout is 3 seconds
|
||||||
|
timeout = 3
|
||||||
|
|
||||||
# Craft the authentication header if required
|
# Craft the authentication header if required
|
||||||
if config['api_key']:
|
if config['api_key']:
|
||||||
headers['X-Api-Key'] = config['api_key']
|
headers['X-Api-Key'] = config['api_key']
|
||||||
|
@ -134,6 +137,7 @@ def call_api(config, operation, request_uri, headers={}, params=None, data=None,
|
||||||
if operation == 'get':
|
if operation == 'get':
|
||||||
response = requests.get(
|
response = requests.get(
|
||||||
uri,
|
uri,
|
||||||
|
timeout=timeout,
|
||||||
headers=headers,
|
headers=headers,
|
||||||
params=params,
|
params=params,
|
||||||
data=data,
|
data=data,
|
||||||
|
@ -142,6 +146,7 @@ def call_api(config, operation, request_uri, headers={}, params=None, data=None,
|
||||||
if operation == 'post':
|
if operation == 'post':
|
||||||
response = requests.post(
|
response = requests.post(
|
||||||
uri,
|
uri,
|
||||||
|
timeout=timeout,
|
||||||
headers=headers,
|
headers=headers,
|
||||||
params=params,
|
params=params,
|
||||||
data=data,
|
data=data,
|
||||||
|
@ -151,6 +156,7 @@ def call_api(config, operation, request_uri, headers={}, params=None, data=None,
|
||||||
if operation == 'put':
|
if operation == 'put':
|
||||||
response = requests.put(
|
response = requests.put(
|
||||||
uri,
|
uri,
|
||||||
|
timeout=timeout,
|
||||||
headers=headers,
|
headers=headers,
|
||||||
params=params,
|
params=params,
|
||||||
data=data,
|
data=data,
|
||||||
|
@ -160,6 +166,7 @@ def call_api(config, operation, request_uri, headers={}, params=None, data=None,
|
||||||
if operation == 'patch':
|
if operation == 'patch':
|
||||||
response = requests.patch(
|
response = requests.patch(
|
||||||
uri,
|
uri,
|
||||||
|
timeout=timeout,
|
||||||
headers=headers,
|
headers=headers,
|
||||||
params=params,
|
params=params,
|
||||||
data=data,
|
data=data,
|
||||||
|
@ -168,6 +175,7 @@ def call_api(config, operation, request_uri, headers={}, params=None, data=None,
|
||||||
if operation == 'delete':
|
if operation == 'delete':
|
||||||
response = requests.delete(
|
response = requests.delete(
|
||||||
uri,
|
uri,
|
||||||
|
timeout=timeout,
|
||||||
headers=headers,
|
headers=headers,
|
||||||
params=params,
|
params=params,
|
||||||
data=data,
|
data=data,
|
||||||
|
|
Loading…
Reference in New Issue