nicolasgrasset / django-celery-transactions Goto Github PK
View Code? Open in Web Editor NEWThis project forked from bradleyayers/django-celery-transactions
Django transaction support for Celery tasks.
License: Other
This project forked from bradleyayers/django-celery-transactions
Django transaction support for Celery tasks.
License: Other
Seems that django-celery-transactions is not compatible with celery v4, isn't it?
celery.contrib.batches
has been removed in celery v4, see: https://celery.readthedocs.io/en/latest/whatsnew-4.0.html
but used here: https://github.com/fellowshipofone/django-celery-transactions/blob/master/djcelery_transactions/__init__.py#L8
Any plans to support celery v4.x ? Or any other hints?
Hello!
First: thank's for this package, it is really useful in our project!
I have one problem: In one of my views a signal is triggered which then calls a celery task like this:
def post_save_donation(sender, instance, created, raw, using, **kwargs):
create_something.delay(pk)
post_save.connect(post_save_donation, sender=Donation)
The task is defined like this:
from djcelery_transactions import task
@task
def create_something(donation_pk):
# do something
Everything works great, but:
If RabbitMQ is down when I am calling the task no error is thrown during the create_something.delay(pk) call. But the view throws this error:
[Errno 111] Connection refused
The question now is: Why is this error thrown in the view but not in the signal handler where the create_something.delay(pk) is called?
Any help is greatly appreciated
I work on a project that uses django-celery-transactions and Django 1.8, but would like to upgrade to Django 1.9. The README warns the 1.9 "will likely require refactoring", so I investigated it a bit and the result is better than expected.
It looks like django-celery-transactions is fine with Django 1.9, despite 1.9's addition of an on_commit()
hook, and the monkey-patching of Atomic.__exit__
will not disable any existing features. Django's on_commit() is actually a method on database connections and doesn't require any code in transaction.Atomic
's __exit__
method. That __exit__
method seems to be identical between 1.8 and 1.9, except for a 2-line change; Django commit 00a1d4d042a7afd139316982c9b57e87d26a894f removes the 'elif connection.features.autocommits_when_autocommit_is_off' block.
Unfortunately it looks like we can't just drop the monkey-patching and use 1.9's on_commit
feature because it's not sufficient to implement what djcelery-transactions needs. 1.9 only has an on-commit hook, and the indexing needs a rollback hook because it needs to either send the tasks (in the case of a successful commit) or discard them (in the case of a rollback). Maybe we could add a wrapper for the __enter__
method that cleared the task queue on initial entry to an atomic block?
I can file a pull request to update the README if you like.
The 0.2 version on PyPi takes issue with Django's 1.6 DatabaseWrapper, see below.
Django==1.6
django-celery-transactions==0.2.0
Exception Type: AttributeError
Exception Value:
'DatabaseWrapper' object has no attribute 'closed_in_transaction'
Exception Location: /tmp/myapp/env/local/lib/python2.7/site-packages/djcelery_transactions/transaction_signals.py in __patched__exit__, line 214
Python Executable: /tmp/myapp/env/bin/python
Python Version: 2.7.6
Python Path:
['/tmp/myapp/market',
'/tmp/myapp/env/lib/python2.7',
'/tmp/myapp/env/lib/python2.7/plat-x86_64-linux-gnu',
'/tmp/myapp/env/lib/python2.7/lib-tk',
'/tmp/myapp/env/lib/python2.7/lib-old',
'/tmp/myapp/env/lib/python2.7/lib-dynload',
'/usr/lib/python2.7',
'/usr/lib/python2.7/plat-x86_64-linux-gnu',
'/usr/lib/python2.7/lib-tk',
'/tmp/myapp/env/local/lib/python2.7/site-packages',
'/tmp/myapp/env/local/lib/python2.7/site-packages/newrelic-2.34.0.29',
'/tmp/myapp/env/local/lib/python2.7/site-packages/setuptools-0.6c11-py2.7.egg-info',
'/tmp/myapp/env/lib/python2.7/site-packages/setuptools-0.6c11-py2.7.egg-info',
'/tmp/myapp/market']Exception Type: AttributeError
Exception Value:
'DatabaseWrapper' object has no attribute 'closed_in_transaction'
Exception Location: /tmp/myapp/env/local/lib/python2.7/site-packages/djcelery_transactions/transaction_signals.py in __patched__exit__, line 214
Python Executable: /tmp/myapp/env/bin/python
Python Version: 2.7.6
Python Path:
['/tmp/myapp/market',
'/tmp/myapp/env/lib/python2.7',
'/tmp/myapp/env/lib/python2.7/plat-x86_64-linux-gnu',
'/tmp/myapp/env/lib/python2.7/lib-tk',
'/tmp/myapp/env/lib/python2.7/lib-old',
'/tmp/myapp/env/lib/python2.7/lib-dynload',
'/usr/lib/python2.7',
'/usr/lib/python2.7/plat-x86_64-linux-gnu',
'/usr/lib/python2.7/lib-tk',
'/tmp/myapp/env/local/lib/python2.7/site-packages',
'/tmp/myapp/env/local/lib/python2.7/site-packages/newrelic-2.34.0.29',
'/tmp/myapp/env/local/lib/python2.7/site-packages/setuptools-0.6c11-py2.7.egg-info',
'/tmp/myapp/env/lib/python2.7/site-packages/setuptools-0.6c11-py2.7.egg-info',
'/tmp/myapp/market']
Hi,
Using Python 3.4, it's not possible to do an import thread
It seems like the 0.3.6 tag wasn't pushed to GitHub
EDIT: By looking at the code it seems Django 1.6 to 1.8 is supported. If that's correct feel free to close the issue - unless you want to update the docs ;)
Hi,
it seems that this fork seems to be maintained in contrary to @bradleyayers original repository. I wondered which django versions are supported by this fork, since it is not clearly mentioned in the docs (started a discussion here bradleyayers#17).
Regards
Jakob
something seems to have gone wrong with the 0.3.0 release.
here https://pypi.python.org/pypi/django-celery-transactions/ it is listed as 0.3.0, so pip says you should upgrade, but if i try to install the 0.3.0 version he then complains that there is no version 0.30 matching.
as i know pip will look up here for the packages:
https://pypi.python.org/simple/django-celery-transactions/
and there the tar file seems missing
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.