Skip to content

Commit 181b0ed

Browse files
author
Naor Livne
committed
adding timeout to all requests sent from the SDK
1 parent 66b4028 commit 181b0ed

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

NebulaPythonSDK/sdk.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -23,49 +23,49 @@ def create_app(self, app, config):
2323
url = self.host + "/api/apps/" + app
2424
payload = json.dumps(config)
2525
headers = self.headers
26-
response = requests.request("POST", url, data=payload, headers=headers)
26+
response = requests.request("POST", url, data=payload, headers=headers, timeout=300)
2727
return response
2828

2929
# delete an existing nebula app, no confirmation required in SDK so be careful
3030
def delete_app(self, app):
3131
url = self.host + "/api/apps/" + app
3232
headers = self.headers
33-
response = requests.request("DELETE", url, headers=headers)
33+
response = requests.request("DELETE", url, headers=headers, timeout=300)
3434
return response
3535

3636
# list all of the apps managed by nebula
3737
def list_apps(self):
3838
url = self.host + "/api/apps"
3939
headers = self.headers
40-
response = requests.request("GET", url, headers=headers)
40+
response = requests.request("GET", url, headers=headers, timeout=300)
4141
return response
4242

4343
# list the config of a nebula app, only requires the app name
4444
def list_app_info(self, app):
4545
url = self.host + "/api/apps/" + app
4646
headers = self.headers
47-
response = requests.request("GET", url, headers=headers)
47+
response = requests.request("GET", url, headers=headers, timeout=300)
4848
return response
4949

5050
# stop a nebula app, only requires the app name
5151
def stop_app(self, app):
5252
url = self.host + "/api/apps/" + app + "/stop"
5353
headers = self.headers
54-
response = requests.request("POST", url, headers=headers)
54+
response = requests.request("POST", url, headers=headers, timeout=300)
5555
return response
5656

5757
# start a nebula app, only requires the app name
5858
def start_app(self, app):
5959
url = self.host + "/api/apps/" + app + "/start"
6060
headers = self.headers
61-
response = requests.request("POST", url, headers=headers)
61+
response = requests.request("POST", url, headers=headers, timeout=300)
6262
return response
6363

6464
# restart a nebula app, only requires the app name
6565
def restart_app(self, app):
6666
url = self.host + "/api/apps/" + app + "/restart"
6767
headers = self.headers
68-
response = requests.request("POST", url, headers=headers)
68+
response = requests.request("POST", url, headers=headers, timeout=300)
6969
return response
7070

7171
# update a nebula app, requires the app name and a dict of the config values you want to change, any combination of
@@ -74,19 +74,19 @@ def update_app(self, app, config):
7474
url = self.host + "/api/apps/" + app + "/update"
7575
payload = json.dumps(config)
7676
headers = self.headers
77-
response = requests.request("PUT", url, data=payload, headers=headers)
77+
response = requests.request("PUT", url, data=payload, headers=headers, timeout=300)
7878
return response
7979

8080
# rolling restart an app, only requires the app name
8181
def roll_app(self, app):
8282
url = self.host + "/api/apps/" + app + "/roll"
8383
headers = self.headers
84-
response = requests.request("POST", url, headers=headers)
84+
response = requests.request("POST", url, headers=headers, timeout=300)
8585
return response
8686

8787
# check that the contacted api is responding as expected
8888
def check_api(self):
8989
url = self.host + "/api/status"
9090
headers = self.headers
91-
response = requests.request("GET", url, headers=headers)
91+
response = requests.request("GET", url, headers=headers, timeout=300)
9292
return response

0 commit comments

Comments
 (0)