Search code examples
pythondjangorabbitmqdjango-celery

Django Celery. How to make tasks execute at the appropriate different times given in variables


I try to make a task that will be done at a certain time. Example: A customer borrowed a book on 01/01/2023 15:00 so the tasks will do exactly one week from now if he doesn't return it and charge a fee. How to make it do at certain different times.

I'm trying to use django celery with rabbitmq, but I'm not succeeding in making this task open at different times only schematically e.g. every 60 minutes


Solution

  • You can check Celery beat for your case https://docs.celeryq.dev/en/stable/userguide/periodic-tasks.html

    In general, what you can do is create:

    1. a task to check your DB instances every 60 minutes and check if you have any upcoming notifications in the next hour.
    2. if you have, trigger a celery task to notify the user when you need it.