sk1pro99
sk1pro99

Reputation: 987

Django Schedule and queue Non periodic Tasks

I am looking for Job Task Scheduler in Django. I have looked into django-celery, but all the documentation shows is the periodic scheduling of task. But what I am looking for is to add a task to queue and schedule it at a specific time, till that time the task can go to sleep. Also, it has to be executed only once. Is my conclusion about django-celery correct? Is there a better way or any other way to schedule non-periodic tasks.

Upvotes: 2

Views: 670

Answers (1)

DRC
DRC

Reputation: 5048

yes, celery is a good tool for the task, the documentation states exactly what you need, specifically just specify an eta when apply_async a task:

from celery import task
from datetime import datetime, timedelta

@task()
def add(x, y):
    return x + y

tomorrow = datetime.now() + timedelta(days=1)
add.apply_async(args=[10, 10], eta=tomorrow)

Upvotes: 3

Related Questions