-
Notifications
You must be signed in to change notification settings - Fork 24
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add initial support for a Celery backend #64
base: master
Are you sure you want to change the base?
Conversation
You are, an absolute legend!
I think deferring to however Celery runs its tasks even without
I think it'd be ideal if we can. By the looks of it, you've got a custom celery App with this, which we could point to As an aside, how viable is making this work without needing a custom app? Perhaps by pointing
I'd say that's absolutely fine! If it supports all the features |
Sounds good 👍
You mean defining a way to configure Celery via the
You need to define a Celery app, which will keep the tasks' registry and be the base to start the worker. I'm adding a minimal/default app here which sets the default queue name (as defined by
Makes sense! |
My main thinking is around people wanting to slowly use It'd be great to be able to configure Celery directly through |
People will be able to use their own. If they are already using Celery with Django, they should have one, and they can still use that one (in that case, there will be already a default_app set, and the worker should be run from that app too, which is likely what they were already doing).
Yeah. Just in case, you can use a custom app as things are now following the Celery docs. If you define your app and make sure it gets loaded when your Django project starts, this will be set as the default app (and then you need to start the worker from this app instead, passing the right path to the I will iterate a few more times on this in the upcoming days (will fix all lint issues, for example :-) will also check any other possible improvements, and will add some tests). Let me know if you have any other thoughts or feedback! |
I would like to follow this development.... |
037c169
to
cbc7824
Compare
This looks very interesting. May I ask what the current status is? There's been no activity for a few months, and it looks like it got close. Is it likely to be merged soon? |
Interested in this as well |
This is an initial PoC for a Celery backend implementation (still in progress, probably requiring some extra work, besides tests).
How to use it:
Using this
django_tasks
branch in your Django project environment, make sure to also install celery:$ pip install celery
Update your
settings.py
to set the Celery backend:You can also set extra celery config in
settings.py
(otherwise it will just use the default values, which should be ok), by defining aCELERY_*
prefixed setting (e.g. to definebroker_url
, you should add a setting forCELERY_BROKER_URL
)If you don't set a broker URL, the expected one would be a local RabbitMQ. You can run it using docker like this:
$ docker run -d -p 5672:5672 rabbitmq
You shouldn't need to change any
django_tasks
related code in your project.Finally, to run the Celery worker:
$ DJANGO_SETTINGS_MODULE=<your_project.settings> celery -A django_tasks.backends.celery.app worker -l INFO
(this uses a simple default Celery app (see
app.py
below) pulling config from Django settings; it can be customized per project if needed)Your tasks should now be queued into RabbitMQ and picked/run by the Celery worker.
(FWIW, I have been using this in a simple personal project, things seem to work for me so far).
A few items to discuss: