django-celery

Django: How to automatically change a field's value at the time mentioned in the same object?

微笑、不失礼 提交于 2019-12-20 09:19:36
问题 I am working on a django project for racing event in which a table in the database has three fields. 1)Boolean field to know whether race is active or not 2)Race start time 3)Race end time While creating an object of it,the start_time and end_time are specified. How to change the value of boolean field to True when the race starts and to False when it ends? How to schedule these activities? 回答1: To automatically update a model field after a specific time, you can use Celery tasks. Step-1:

Django & Celery — Routing problems

旧街凉风 提交于 2019-12-20 08:51:25
问题 I'm using Django and Celery and I'm trying to setup routing to multiple queues. When I specify a task's routing_key and exchange (either in the task decorator or using apply_async() ), the task isn't added to the broker (which is Kombu connecting to my MySQL database). If I specify the queue name in the task decorator (which will mean the routing key is ignored), the task works fine. It appears to be a problem with the routing/exchange setup. Any idea what the problem could be? Here's the

Can I use java send task to celery through rabbitmq?

China☆狼群 提交于 2019-12-20 02:30:40
问题 I just touch celery and java for 2 days. :( Right now, I have a task that java client send task through rabbitmq. Celery will be the worker to handle task. I know it's easy for Python->rabbitmq->celery. But can I do this by java->rabbitmq->celery ? The draft idea is that serialization the java function by JSON and then send by rabbitmq, and then handle by celery. It's better to have example code and could be run directly thanks 回答1: You can certainly send messages through RabbitMQ from Java.

Celery revoke task before execute using django database

霸气de小男生 提交于 2019-12-19 11:35:26
问题 I'm using Django database instead of RabbitMQ for concurrency reasons. But I can't solve the problem of revoking a task before it execute. I found some answers about this matter but they don't seem complete or I can't get enough help. first answer second answer How can I extend celery task table using a model, add a boolean field (revoked) to set when I don't want the task to execute? Thanks. 回答1: Since Celery tracks tasks by an ID, all you really need is to be able to tell which IDs have

Why would running scheduled tasks with Celery be preferable over crontab?

一世执手 提交于 2019-12-17 21:49:19
问题 Considering Celery is already a part of the stack to run task queues (i.e. it is not being added just for running crons, that seems an overkill IMHO ). How can its "periodic tasks" feature be beneficial as a replacement for crontab ? Specifically looking for following points. Major pros/cons over crontab Use cases where celery is better choice than crontab Django specific use case: Celery vs crontab to run django based periodic tasks, when celery has been included in the stack as django

celery - chaining groups and subtasks. -> out of order execution

走远了吗. 提交于 2019-12-17 18:14:22
问题 When I have something like the following group1 = group(task1.si(), task1.si(), task1.si()) group2 = group(task2.si(), task2.si(), task2.si()) workflow = chain(group1, group2, task3.si()) The intuitive interpretation is that task3 should only execute after all tasks in group 2 have finished. In reality, task 3 executes while group1 has started but hasn't completed yet. What am i doing wrong? 回答1: So as it turns out, in celery you cannot chain two groups together. I suspect this is because

Stopping/Purging Periodic Tasks in Django-Celery

夙愿已清 提交于 2019-12-17 17:59:07
问题 I have managed to get periodic tasks working in django-celery by subclassing PeriodicTask. I tried to create a test task and set it running doing something useless. It works. Now I can't stop it. I've read the documentation and I cannot find out how to remove the task from the execution queue. I have tried using celeryctl and using the shell, but registry.tasks() is empty, so I can't see how to remove it. I have seen suggestions that I should "revoke" it, but for this I appear to need a task

How to run a celery worker with Django app scalable by AWS Elastic Beanstalk?

若如初见. 提交于 2019-12-17 10:32:16
问题 How to use Django with AWS Elastic Beanstalk that would also run tasks by celery on main node only? 回答1: This is how I set up celery with django on elastic beanstalk with scalability working fine. Please keep in mind that 'leader_only' option for container_commands works only on environment rebuild or deployment of the App. If service works long enough, leader node may be removed by Elastic Beanstalk. To deal with that, you may have to apply instance protection for your leader node. Check:

How to use (django-celery,RQ) worker to execute a video filetype conversion (ffmpeg) in django on heroku (My code works locally)

Deadly 提交于 2019-12-14 03:58:20
问题 One part of my website includes a form that allows users to upload video. I use ffmpeg to convert the video to flv. My media and static files are stored on Amazon S3. I can get everything to work perfectly locally, however I can't seem to figure out how to use a worker to run the video conversion subprocess in production. I have dj-celery and rq installed in my app. The code in my view that I was able to get to work locally is: #views.py def upload_broadcast(request): if request.method ==

Decorator after @task decorator in celery

爷,独闯天下 提交于 2019-12-14 00:17:13
问题 I'm trying to apply a decorator after the celery @task decorator, something like. @send_email @task def any_function(): print "inside the function" I can get it to work in the way it is recommended in the docs, i.e. to put the decorator before the task decorator, but in this case I would like to access the task instance in my decorator. The @send_email would have to be a class decorator, this is what I tried without success: class send_email(object): ''' wraps a Task celery class ''' def _