I want to send an email to my users exactly 48 hours after they have registered.How do i achieve this using celery? If I create a periodic task to send an email, I will have to decide a specific time during which i want to execute that task. I don't want to keep run a celery task every second to check if there are any emails needed to be sent.
Asked
Active
Viewed 6,132 times
1 Answers
40
You'll want to make use of ETA. Read that section of the docs as it'll have more information. However, your code will look something like this:
from datetime import datetime, timedelta
send_date = datetime.utcnow() + timedelta(days=2)
email_user.apply_async([user], eta=send_date)

schillingt
- 13,493
- 2
- 32
- 34