Celery wrapper that delays tasks until the django transaction has committed
Project description
# django-celery-oncommit
Delay all celery tasks until after the current django transaction has committed to prevent race conditions.
See the [django docs](https://docs.djangoproject.com/en/2.1/topics/db/transactions/#performing-actions-after-commit) for more details.
## Usage
`pip install django-celery-oncommit`
In your task file:
```python
from django_celery_oncommit import task
@task
def some_task(with_args):
"""Task that does stuff with objects"""
pass
```
Elsewhere:
```python
from mytasks import some_task
def function_used_in_django_code():
create_some_objects()
some_task.delay(args_referring_to_new_objects)
slow_operation_that_allows_the_race_condition()
```
Ta da!
## TODO
* provide a non-transaction-based option `apply_async` for when the user explicity knows how they want to interact with transactions
Delay all celery tasks until after the current django transaction has committed to prevent race conditions.
See the [django docs](https://docs.djangoproject.com/en/2.1/topics/db/transactions/#performing-actions-after-commit) for more details.
## Usage
`pip install django-celery-oncommit`
In your task file:
```python
from django_celery_oncommit import task
@task
def some_task(with_args):
"""Task that does stuff with objects"""
pass
```
Elsewhere:
```python
from mytasks import some_task
def function_used_in_django_code():
create_some_objects()
some_task.delay(args_referring_to_new_objects)
slow_operation_that_allows_the_race_condition()
```
Ta da!
## TODO
* provide a non-transaction-based option `apply_async` for when the user explicity knows how they want to interact with transactions
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file django-celery-oncommit-0.0.2.tar.gz.
File metadata
- Download URL: django-celery-oncommit-0.0.2.tar.gz
- Upload date:
- Size: 2.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.19.1 setuptools/40.2.0 requests-toolbelt/0.8.0 tqdm/4.26.0 CPython/2.7.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4e2c38262d17be928f5a36726577aa8524f0b212cf4d6b984271968ea713987e
|
|
| MD5 |
224e9a5d87f742fdbf82b0d557f8ef83
|
|
| BLAKE2b-256 |
9041ba6c9499c085629bed94e5d016c2faf1354111e06fdcf83937ea1e2bcf9d
|
File details
Details for the file django_celery_oncommit-0.0.2-py2-none-any.whl.
File metadata
- Download URL: django_celery_oncommit-0.0.2-py2-none-any.whl
- Upload date:
- Size: 2.4 kB
- Tags: Python 2
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.19.1 setuptools/40.2.0 requests-toolbelt/0.8.0 tqdm/4.26.0 CPython/2.7.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8602ac1af6cc129c2c113d8c9e9e4955a39bebea8d8141708846172db22de3e6
|
|
| MD5 |
b31d8549fa90df323600627c572f4ed8
|
|
| BLAKE2b-256 |
f65da148d15439965b7e11ac3b7215a2ed3809ca26f60b3b9f33cf89d8feb28f
|