celery

AttributeError: 'Flask' object has no attribute 'user_options'

烂漫一生 提交于 2019-11-28 16:41:52
问题 I am trying to setup this basic example from the following doc: http://flask.pocoo.org/docs/patterns/celery/ But so far I keep getting the below error: AttributeError: 'Flask' object has no attribute 'user_options' I am using celery 3.1.15. from celery import Celery def make_celery(app): celery = Celery(app.import_name, broker=app.config['CELERY_BROKER_URL']) celery.conf.update(app.config) TaskBase = celery.Task class ContextTask(TaskBase): abstract = True def __call__(self, *args, **kwargs):

Celery Flower Security in Production

帅比萌擦擦* 提交于 2019-11-28 16:29:00
问题 I am looking to use Flower (https://github.com/mher/flower) to monitor my Celery tasks in place of the django-admin as reccomended in their docs (http://docs.celeryproject.org/en/latest/userguide/monitoring.html#flower-real-time-celery-web-monitor). However, because I am new to this I am a little confused about the way Flower's page is only based on HTTP, and not HTTPS. How can I enable security for my Celery tasks such that any old user can't just visit the no-login-needed website http:/

How to inspect and cancel Celery tasks by task name

纵饮孤独 提交于 2019-11-28 16:23:48
I'm using Celery (3.0.15) with Redis as a broker. Is there a straightforward way to query the number of tasks with a given name that exist in a Celery queue? And, as a followup, is there a way to cancel all tasks with a given name that exist in a Celery queue? I've been through the Monitoring and Management Guide and don't see a solution there. # Retrieve tasks # Reference: http://docs.celeryproject.org/en/latest/reference/celery.events.state.html query = celery.events.state.tasks_by_type(your_task_name) # Kill tasks # Reference: http://docs.celeryproject.org/en/latest/userguide/workers.html

What's the equivalent of Python's Celery project for Java?

心不动则不痛 提交于 2019-11-28 16:15:47
问题 I am trying to find an equivalent of Celery project for Java environment, I have looked at Spring Batch, but are there any better alternatives for distributed task queues. Thanks. 回答1: What Celery is doing is very much akin to EIP, and SEDA with convenient task scheduling... (all you have left to do is add some DB, and async HTTP networking and you have got a complete enterprise quality stack). Basically in Java there is the Spring way, the Java EE way, and the Hadoop way: Spring: Spring

How do I restart celery workers gracefully?

戏子无情 提交于 2019-11-28 16:12:21
While issuing a new build to update code in workers how do I restart celery workers gracefully? Edit: What I intend to do is to something like this. Worker is running, probably uploading a 100 MB file to S3 A new build comes Worker code has changes Build script fires signal to the Worker(s) Starts new workers with the new code Worker(s) who got the signal after finishing the existing job exit. The new recommended method of restarting a worker is documented in here http://docs.celeryproject.org/en/latest/userguide/workers.html#restarting-the-worker $ celery multi start 1 -A proj -l info -c4 -

How do you unit test a Celery task?

℡╲_俬逩灬. 提交于 2019-11-28 16:02:16
The Celery documentation mentions testing Celery within Django but doesn't explain how to test a Celery task if you are not using Django. How do you do this? It is possible to test tasks synchronously using any unittest lib out there. I normaly do 2 different test sessions when working with celery tasks. The first one (as I'm suggesting bellow) is completely synchronous and should be the one that makes sure the algorithm does what it should do. The second session uses the whole system (including the broker) and makes sure I'm not having serialization issues or any other distribution,

In celery 3.1, making django periodic task

谁说我不能喝 提交于 2019-11-28 15:59:47
Things changed too much in Django, so I can't use 3.1. I need some help. I read about make a task in django , and read Periodic Tasks document. But I don't know how make periodic tasks in django. I think this becuase of my low level English.. In the older version of Celery, I imported djcelery & crontab and set CELERYBEAT_SCHEDULE in settings.py , and excuted by manage.py . But it seems that I cannot execute celery deamon by that way anymore. Than where I should put CELERYBEAT_SCHEDULE? In django example in docs, they set os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'proj.settings') in proj

Deleting all pending tasks in celery / rabbitmq

泪湿孤枕 提交于 2019-11-28 15:00:19
How can I delete all pending tasks without knowing the task_id for each task? Philip Southam From the docs : $ celery -A proj purge or from proj.celery import app app.control.purge() (EDIT: Updated with current method.) ToonAlfrink For celery 3.0+: $ celery purge To purge a specific queue: $ celery -Q queue_name purge smido For Celery 2.x and 3.x: When using worker with -Q parameter to define queues, for example celery worker -Q queue1,queue2,queue3 then celery purge will not work, because you cannot pass the queue params to it. It will only delete the default queue. The solution is to start

Why do we need message brokers like RabbitMQ over a database like PostgreSQL?

僤鯓⒐⒋嵵緔 提交于 2019-11-28 14:57:19
I am new to message brokers like RabbitMQ which we can use to create tasks / message queues for a scheduling system like Celery . Now, here is the question: I can create a table in PostgreSQL which can be appended with new tasks and consumed by the consumer program like Celery. Why on earth would I want to setup a whole new tech for this like RabbitMQ? Now, I believe scaling cannot be the answer since our database like PostgreSQL can work in a distributed environment. I googled for what problems does the database poses for the particular problem, and I found: polling keeps the database busy

Celery and Django simple example

笑着哭i 提交于 2019-11-28 14:57:13
问题 Let's take a simple Django example. app/models.py from django.db import models from django.contrib.auth.models import User class UserProfile(models.Model): user = models.OneToOneField(User) token = models.CharField(max_length=32) app/views.py from django.http import HttpResponse from django.views.decorators.csrf import csrf_exempt from forms import RegisterForm from utils.utilities import create_user @csrf_exempt def register_view(request): if request.method == 'POST': form = RegisterForm