User management of periodic tasks in django celery app - django

Django celery (djcelery) is considered obselete these days, but to me it seems to offer some unique features still. For example with djcelery one can allow the user to add a periodic task easily by creating an instance of their PeriodicTask. Is this the best way to do this? If not how else could I allow users to manage periodic tasks in a django+celery app?
(Just to be clear I know I can hardcode periodic tasks in settings.py celery beat schedule with djcelery, but I'm talking about user management of periodic tasks, creating/updating/listing/deleting, via the admin or some mini app which interfaces a model like djcelery's PeriodicTask model)

Related

Dynamic periodic tasks - alternatives to Celery beat

If one wants to set up dynamic and standard periodic tasks scheduling and in a Django project, are there any stable alternatives to celery and celery beat? (when I say dynamic I mean such thing as described here)
Would Dramatiq or any other schedulers, for instance, allow for such customization as dynamic user-launched schedulling of periodic tasks?
Or are there any other strategies for creating some kind of dynamic schedule with periodic tasks for Django in general ?
There is a way to configure jobs in Django.
There is a good and helpful extension called django-crontab GitHub Repo. This could be something that will allow you to do what you need. This will tie in with Django specific as requested. Hope this is some help you on your alternative to Celery beats.
Have a good day.
Yes I had the same problem with django-celery-beat the problem is you cannot manage the periodic tasks dynamically (changing the schedule or adding the task itself on a running celery worker), to overcome this issue you can use this library djang-redbeat which does exactly what you want. The only difference is the CELERY_BEAT_SCHEDULER this library uses Redis database to store the tasks and their results.
https://pypi.org/project/django-redbeat/

Can I edit cronjobs using my Django application?

I am creating a Django application for school project. I want to schedule jobs (every (work)day on 9:00 and 17:00).
I am trying to do it with Celery right now, but I stuck very hard on it, and as the deadline is in sight, I want to use alternative options: just a cronjob. I think just the cronjob works fine, but the user should be able to edit the times of the cronjobs using the Django web application (so not logging in to SSH, edit the crontab manually).
Is this possible? Can't find anything about it on the internet.
You need django-celery-beat plugin that adds new models to the django admin named "Periodic tasks" where you can manage cron schedule for your tasks.
As an alternate, if you really do not want to run a background tasks, you can create django management commands and use a library like python-crontab to add/modify/remove cron jobs in the system.

Scheduling task from Django admin Panel

I want to schedule a task in Django which would run at a paticular time every day.I am thinking of using celery to schedule the tasks so I wanted to know is there anyway through celery-beat I could execute the task through admin panel that is make it active or inactive and give the time at which I want to execute task through my admin site.Instead of writing this in my code
crontab(day_of_week="0,6", hour="0,12", minute=15)
I want to pass it through my admin panel so that in future if I want to execute my task at some other time I could change it directly through admin panel instead of changing my code.
You will need to implement that on your own or use a third-party project. Luckily, someone already created something like that:
https://django-celery-beat.readthedocs.io/
This extension enables you to store the periodic task schedule in the
database.
The periodic tasks can be managed from the Django Admin interface,
where you can create, edit and delete periodic tasks and how often
they should run.

Django Signals and celery , is Sync

I am using celery to scrap some URLs , and pushing the scrap data to an API
but because of quick calls on this API
i need to use Django Signals if it Sync
you can use periodic tasks in celery can you give more specific details what you want to exactly do

Dynamic Celery Scheduling

Using Django & Celery is it possible to add/modify the scheduler dynamically from code and have it update in real time.
I noticed the /admin/djcelery/periodictask/add/ option in the admin panel to add periodic tasks but how can this be done from my Django views?
Ideally I'd be able to add multiple period tasks with the same task but different arguments
Just create a periodictask object.
from djcelery.models import PeriodicTask
PeriodicTask.objects.create(...)
You may have problems because you may need to restart celerybeat.. to reload all periodic tasks.