Welcome to Celery Persistent Revokes’s documentation!¶
Contents:
Celery Persistent Revokes¶
Celery task revokes are stored on memory or on file. This packages makes possible to easily customize how your revokes are stored (Ex.: Database).
Documentation¶
The full documentation is at https://celery-persistent-revokes.readthedocs.io.
Quickstart¶
Install Celery Persistent Revokes:
pip install celery-persistent-revokes
Add it to your INSTALLED_APPS:
INSTALLED_APPS = (
...
'celery_persistent_revokes.apps.CeleryPersistentRevokesConfig',
...
)
Add Celery Persistent Revokes’s URL patterns:
from celery_persistent_revokes import urls as celery_persistent_revokes_urls
urlpatterns = [
...
url(r'^', include(celery_persistent_revokes_urls)),
...
]
Features¶
- Built-in tasks revokes using Django default database
- Support for custom backends
Running Tests¶
Does the code actually work?
source <YOURVIRTUALENV>/bin/activate
(myenv) $ pip install tox
(myenv) $ tox
Installation¶
At the command line:
$ easy_install celery-persistent-revokes
Or, if you have virtualenvwrapper installed:
$ mkvirtualenv celery-persistent-revokes
$ pip install celery-persistent-revokes
Usage¶
Django Projects¶
To use Celery Persistent Revokes in a Django project, add it to your INSTALLED_APPS:
INSTALLED_APPS = (
...
'celery_persistent_revokes.apps.CeleryPersistentRevokesConfig',
...
)
Run migrations:
Use revokable_task()
decorator to create tasks:
from celery_persistent_revokes.decorators import revokable_task
@revokable_task(my_celery_app)
def my_pretty_task(my_arg):
do_something(my_arg)
return
Use revoke()
helper to create tasks:
from celery_persistent_revokes.helpers import revoke
result = my_pretty_task.delay()
# ...
revoke(result.id)
Other Python Projects¶
To use Celery Persistent Revokes without Django, you need to implement your own task management backend. But don’t panic, this is pretty straight forward:
class MyCustomBackend(object):
def revoke(self, task_id):
# save on your storage the id of the task to be revoked
def list_revokes(self):
# list the ids of your revoked tasks
def is_task_revoked(self, task_id):
# returns True if the task with the id equal to task_id
# is marked as revoked in your storage
def delete_revoke(self, task_id):
# removes the revoked task with id equal to task_id from
# your storage
Then you just need to set the path to MyCustomBackend in an environment variable called CELERY_PERSISTENT_REVOKES_BACKEND.
Supposing that you have the following file structure and MyCustomBackend is in a task_revoke_backends module:
$ export CELERY_PERSISTENT_REVOKES_BACKEND='task_revoke_backends.MyCustomBackend'
Configuration¶
Configurations can be set as environment variables and as Django settings too (in case your project uses Django.
The variables are:
- CELERY_PERSISTENT_REVOKES_BACKEND:
- Default value: ‘celery_persistent_revokes.backends.DjangoDatabase’. This variable defines the backend used to store and fetch the tasks ids of the tasks you revoke using this package.
- CELERY_PERSISTENT_REVOKES_MODEL:
Default value: ‘celery_persistent_revokes.CeleryTaskRevoke’. If you’re using DjangoDatabase backend, you can use this variable to define another Django model to store your Revokes.
from django.db import models from celery_persistent_revokes.models import CeleryTaskRevoke class MyCustomRevoke(CeleryTaskRevoke) created = models.DateTimeField(auto_now=True)
Contributing¶
Contributions are welcome, and they are greatly appreciated! Every little bit helps, and credit will always be given.
You can contribute in many ways:
Types of Contributions¶
Report Bugs¶
Report bugs at https://github.com/vintasoftware/celery-persistent-revokes/issues.
If you are reporting a bug, please include:
- Your operating system name and version.
- Any details about your local setup that might be helpful in troubleshooting.
- Detailed steps to reproduce the bug.
Fix Bugs¶
Look through the GitHub issues for bugs. Anything tagged with “bug” is open to whoever wants to implement it.
Implement Features¶
Look through the GitHub issues for features. Anything tagged with “feature” is open to whoever wants to implement it.
Write Documentation¶
Celery Persistent Revokes could always use more documentation, whether as part of the official Celery Persistent Revokes docs, in docstrings, or even on the web in blog posts, articles, and such.
Submit Feedback¶
The best way to send feedback is to file an issue at https://github.com/vintasoftware/celery-persistent-revokes/issues.
If you are proposing a feature:
- Explain in detail how it would work.
- Keep the scope as narrow as possible, to make it easier to implement.
- Remember that this is a volunteer-driven project, and that contributions are welcome :)
Get Started!¶
Ready to contribute? Here’s how to set up celery-persistent-revokes for local development.
Fork the celery-persistent-revokes repo on GitHub.
Clone your fork locally:
$ git clone git@github.com:your_name_here/celery-persistent-revokes.git
Install your local copy into a virtualenv. Assuming you have virtualenvwrapper installed, this is how you set up your fork for local development:
$ mkvirtualenv celery-persistent-revokes $ cd celery-persistent-revokes/ $ pip install -r requirements/dev.txt $ python setup.py develop
Create a branch for local development:
$ git checkout -b name-of-your-bugfix-or-feature
Now you can make your changes locally.
When you’re done making changes, check that your changes pass prospector and the tests, including testing other Python versions with tox:
$ prospector $ python setup.py test $ make test-all
To get prospector and tox, just pip install them into your virtualenv.
Commit your changes and push your branch to GitHub:
$ git add . $ git commit -m "Your detailed description of your changes." $ git push origin name-of-your-bugfix-or-feature
Before every commit, pre-commit runs some checks to make sure the changes are according to the project’s code style.
If, for some reason, you need to commit without running the checks, you can skip them by using a -n flag:
$ git commit -m "Your detailed description of your changes." -n
Submit a pull request through the GitHub website.
Pull Request Guidelines¶
Before you submit a pull request, check that it meets these guidelines:
- The pull request should include tests.
- If the pull request adds functionality, the docs should be updated. Put your new functionality into a function with a docstring, and add the feature to the list in README.rst.
- The pull request should work for Python 2.7, 3.4, 3.5 and 3.6. Check https://travis-ci.org/vintasoftware/celery-persistent-revokes/pull_requests and make sure that the tests pass for all supported Python versions.
Credits¶
Development Lead¶
- Hugo Bessa <hugo@vinta.com.br>
Contributors¶
None yet. Why not be the first?