Skip to content

Commit

Permalink
Add 5 minute timeout to requests.get() calls. (#18)
Browse files Browse the repository at this point in the history
  • Loading branch information
felixfontein authored Dec 11, 2023
1 parent 85f7604 commit 0ab6f6e
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
3 changes: 2 additions & 1 deletion inventory/cloudforms.py
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,8 @@ def _http_request(self, url):

ret = requests.get(url,
auth=HTTPBasicAuth(self.cloudforms_username, self.cloudforms_pw),
verify=self.cloudforms_ssl_verify)
verify=self.cloudforms_ssl_verify,
timeout=300)

ret.raise_for_status()

Expand Down
2 changes: 1 addition & 1 deletion inventory/phpipam_inventory.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
"Content-Type": "application/json"
}

response = requests.get(url, headers=headers)
response = requests.get(url, headers=headers, timeout=300)
print("*********************************************")
# Uncomment the below two lines to help when troublshooting to dump the contents of the API call to the console.

Expand Down
4 changes: 2 additions & 2 deletions inventory/rackhd.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def _load_inventory_data(self, nodeid):

results = {}
for (key, url) in info.items():
r = requests.get(url, verify=False)
r = requests.get(url, verify=False, timeout=300)
results[key] = r.text
self._inventory[nodeid] = results

Expand Down Expand Up @@ -76,7 +76,7 @@ def parse_args():
if (parse_args().list):
try:
url = RACKHD_URL + '/api/common/nodes'
r = requests.get(url, verify=False)
r = requests.get(url, verify=False, timeout=300)
data = json.loads(r.text)
for entry in data:
if entry['type'] == 'compute':
Expand Down

0 comments on commit 0ab6f6e

Please sign in to comment.