I work for an organization that sends sms to users based on subscription, my stack has Django, Celery, Redis, RabbitMQ, PostgreSQL, Apache, nginx and Kannel. In this environment every SMS service provider has a certain period of time in which we can send SMS.
Let's say that i have a celery task that makes a billing request to a carrier webservice, if the billing is successful i have to send an SMS, is there a way to schedule this task to be sent between a certain period, say 8am to 6pm? I know that i can specify an eta and a expiration, however i do not want my tasks to expire because i do have to send the SMS so i will send them the next day
You can put SMSs in a queue and use crontab shceduler to send them in specific times. The example below executes the tasks.send_sms task every 10 minutes between 8 and 6.
http://ask.github.com/celery/userguide/periodic-tasks.html#crontab-schedules
from celery.schedules import crontab
CELERYBEAT_SCHEDULE = {
"every-10-mins-between-8-6": {
"task": "tasks.send_sms",
"schedule": crontab(minute="*/10", hour="8,18"),
}, }