diff --git a/app/celery/research_mode_tasks.py b/app/celery/research_mode_tasks.py index d7ecb399e..274fa3fe4 100644 --- a/app/celery/research_mode_tasks.py +++ b/app/celery/research_mode_tasks.py @@ -55,7 +55,8 @@ def make_request(notification_type, provider, data, headers): "POST", api_call, headers=headers, - data=data + data=data, + timeout=5 ) response.raise_for_status() except RequestException as e: diff --git a/app/clients/sms/firetext.py b/app/clients/sms/firetext.py index 911c88bda..17e09e967 100644 --- a/app/clients/sms/firetext.py +++ b/app/clients/sms/firetext.py @@ -97,7 +97,8 @@ class FiretextClient(SmsClient): response = request( "POST", self.url, - data=data + data=data, + timeout=60 ) response.raise_for_status() try: diff --git a/app/clients/sms/mmg.py b/app/clients/sms/mmg.py index 642a247a9..7e3a18e47 100644 --- a/app/clients/sms/mmg.py +++ b/app/clients/sms/mmg.py @@ -1,7 +1,7 @@ import json from monotonic import monotonic from requests import (request, RequestException) - +from requests.exceptions import HTTPError from app.clients import (STATISTICS_DELIVERED, STATISTICS_FAILURE) from app.clients.sms import (SmsClient, SmsClientResponseException) @@ -104,7 +104,8 @@ class MMGClient(SmsClient): headers={ 'Content-Type': 'application/json', 'Authorization': 'Basic {}'.format(self.api_key) - } + }, + timeout=60 ) response.raise_for_status() @@ -117,6 +118,9 @@ class MMGClient(SmsClient): except RequestException as e: self.record_outcome(False, e.response) raise MMGClientResponseException(response=e.response, exception=e) + except HTTPError as e: + self.record_outcome(False, e.response) + raise MMGClientResponseException(response=e.response, exception=e) finally: elapsed_time = monotonic() - start_time self.statsd_client.timing("clients.mmg.request-time", elapsed_time) diff --git a/app/notifications/notifications_sms_callback.py b/app/notifications/notifications_sms_callback.py index 3c569e158..c1eacdee4 100644 --- a/app/notifications/notifications_sms_callback.py +++ b/app/notifications/notifications_sms_callback.py @@ -11,6 +11,8 @@ register_errors(sms_callback_blueprint) @sms_callback_blueprint.route('/mmg', methods=['POST']) def process_mmg_response(): + from time import sleep + sleep(20) client_name = 'MMG' data = json.loads(request.data) errors = validate_callback_data(data=data,