
    ;i                         d dl mZ d dlZd dlmZ d dlmZ  ej                  e      Z	 eddd      d	e
d
e
fd       Zy)    )shared_taskN)get_twilio_client)settingsT   
   )bindmax_retriesdefault_retry_delay	to_numbermessagec                 b   	 |st         j                  d       yt               }|j                  j	                  |t
        j                  |      }t         j                  d| d|j                          y# t        $ r/}t         j                  d|        | j                  |      d	}~ww xY w)
zd
    Celery task to send SMS asynchronously using Twilio.
    Retries automatically on failure.
    z7Celery SMS task failed: no destination number provided.F)bodyfrom_toz[CELERY] SMS sent to z, SID=Tz4[CELERY] Twilio SMS send failed, will retry. Error: )excN)loggererrorr   messagescreater   TWILIO_FROM_NUMBERinfosid	Exception	exceptionretry)selfr   r   twilio_clientsmsr   s         G/var/www/html/dp2/backend_v2.1/server/apps/calls/tasks/send_sms_task.pysend_sms_taskr    	   s    "LLRS)+$$++-- , 
 	+I;fSWWIFG "OPSuUVjjSj!!"s   A6 AA6 6	B.?*B))B.)celeryr   loggingapps.calls.servicesr   django.confr   	getLogger__name__r   strr         r   <module>r*      sS      1  			8	$ 	
"3 " "
"r)   