diff --git a/app/config.py b/app/config.py index c50d8a6744..f69f9fdeb9 100644 --- a/app/config.py +++ b/app/config.py @@ -491,6 +491,7 @@ class Config(object): } CELERY_QUEUES: List[Any] = [] CELERY_DELIVER_SMS_RATE_LIMIT = os.getenv("CELERY_DELIVER_SMS_RATE_LIMIT", "1/s") + AWS_SEND_SMS_BOTO_CALL_LATENCY = os.getenv("AWS_SEND_SMS_BOTO_CALL_LATENCY", 0.06) # average delay in production CONTACT_FORM_EMAIL_ADDRESS = os.getenv("CONTACT_FORM_EMAIL_ADDRESS", "helpdesk@cds-snc.ca") diff --git a/app/delivery/send_to_providers.py b/app/delivery/send_to_providers.py index 1457f71f04..dfac94cb69 100644 --- a/app/delivery/send_to_providers.py +++ b/app/delivery/send_to_providers.py @@ -2,6 +2,7 @@ import os import re from datetime import datetime +from time import sleep from typing import Any, Dict, Optional from uuid import UUID @@ -99,13 +100,16 @@ def send_sms_to_provider(notification): elif ( validate_and_format_phone_number(notification.to, international=notification.international) - == Config.INTERNAL_TEST_NUMBER + == current_app.config["INTERNAL_TEST_NUMBER"] ): - current_app.logger.info(f"notification {notification.id} sending to internal test number. Not sending to AWS") + current_app.logger.info(f"notification {notification.id} sending to internal test number. Not sending to AWS.") notification.reference = send_sms_response(provider.get_name(), notification.to) notification.billable_units = template.fragment_count update_notification_to_sending(notification, provider) - + current_app.logger.info( + f"Sleeping {current_app.config['AWS_SEND_SMS_BOTO_CALL_LATENCY']} seconds to simulate AWS boto call latency." + ) + sleep(current_app.config["AWS_SEND_SMS_BOTO_CALL_LATENCY"]) # simulate boto3 client send_sms() delay else: try: template_category_id = template_dict.get("template_category_id")