Skip to content

Commit fa3204b

Browse files
committed
[Improvement] Added timeout to request.post #1049
Added timeout parameter to request.post with verify variable simplification. Guard against missing action parameter to prevent AttributeError. Fixes #1049
1 parent b456ee2 commit fa3204b

2 files changed

Lines changed: 3 additions & 2 deletions

File tree

openwisp_controller/config/tasks.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,8 @@ def trigger_vpn_server_endpoint(endpoint, auth_token, vpn_id):
137137
response = requests.post(
138138
endpoint,
139139
params={"key": auth_token},
140-
verify=False if getattr(settings, "DEBUG") else True,
140+
verify=not settings.DEBUG,
141+
timeout=30,
141142
)
142143
response.raise_for_status()
143144
except requests.RequestException as e:

openwisp_controller/config/utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ def get_config_error_notification_target_url(obj, field, absolute_url=True):
213213

214214
def send_api_task_notification(type, **kwargs):
215215
vpn = kwargs.get("instance")
216-
action = kwargs.get("action").replace("_", " ")
216+
action = kwargs.get("action", "").replace("_", " ")
217217
exception = kwargs.get("exception")
218218
# Adding some delay here to prevent overlapping
219219
# of the django success message container

0 commit comments

Comments
 (0)