Skip to content

Commit

Permalink
Merge pull request #10 from fellowshipofone/django-18
Browse files Browse the repository at this point in the history
Django 1.8 support
  • Loading branch information
nicolasgrasset committed Jun 3, 2015
2 parents 9c30370 + e1987c9 commit 4285be5
Show file tree
Hide file tree
Showing 12 changed files with 296 additions and 296 deletions.
14 changes: 10 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,22 @@ python:
- "3.3"
- "3.4"

services: mysql

env:
- DJANGO="django==1.7.6"
- DJANGO="django==1.6.10"
- DJANGO="django==1.5.12"
- DJANGO="django==1.8.2" DB="mysql"
- DJANGO="django==1.7.8" DB="mysql"
- DJANGO="django==1.6.10" DB="mysql"

install:
- pip install $DJANGO
- pip install celery==3.1.16
- pip install celery==3.1.18
- pip install django-celery==3.1.16
- pip install coveralls
- pip install mysqlclient

before_script:
- mysql -e 'create database testdb;'

script:
- coverage run --source=djcelery_transactions runtests.py
Expand Down
39 changes: 37 additions & 2 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,10 +1,43 @@
Changelog
=========

0.3.1 (2015-04-17)
0.3.2 (unreleased)
------------------------

- Having issues with Pypi when uploading file, trying again with new version
- Drop support for Django 1.5. [Nicolas Grasset]

- Travis test with MySQL backend. Fixes #7. [Nicolas Grasset]

#7 is not “fixed”, but if the tests pass, I’ll need more details about
the issue


- Pkg 0.3.2 change log. [Nicolas Grasset]

- Pkg: Drop test support for Django 1.5. [Nicolas Grasset]

- Trigger tasks in inner savepoint commits. [Nicolas Grasset]

This is a rollback of
https://github.com/fellowshipofone/django-celery-transactions/commit/c3d
2b704101ed90b0d6eebec0f0b8acc9ff1b617 by @sheats but I think it is
cleaner this way, and it is required for new Django 1.8 tests since
they are nested in atomic blocks


- Django 1.8 extra not compatible with TransactionTestCase. [Nicolas
Grasset]

- Make Django 1.8 code update compatible with 1.5. [Nicolas Grasset]

- Pkg: Update from Django 1.8 source. [Nicolas Grasset]

- Pkg: Cleanup test structure for extra 1.8 test. [Nicolas Grasset]

- [tests] Check Django 1.8 logic. [Nicolas Grasset]

0.3.1 (2015-04-18)
------------------

Changes
~~~~~~~
Expand All @@ -14,6 +47,8 @@ Changes
Other
~~~~~

- 0.3.1 PyPi upload issues. Fixes #9. [Nicolas Grasset]

- Pkg: Fix PyPi file. [Nicolas Grasset]

0.3.0 (2015-03-14)
Expand Down
36 changes: 6 additions & 30 deletions djcelery_transactions/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@
from django.conf import settings
from django.db import transaction

if django.VERSION >= (1, 6):
from django.db.transaction import get_connection, atomic
from django.db.transaction import get_connection, atomic

import djcelery_transactions.transaction_signals

Expand Down Expand Up @@ -110,28 +109,11 @@ def apply_async(self, *args, **kwargs):
eager_transaction = _get_celery_settings('CELERY_EAGER_TRANSACTION',
not celery_eager)

if django.VERSION < (1, 6):

if transaction.is_managed() and eager_transaction:
if not transaction.is_dirty():
# Always mark the transaction as dirty
# because we push task in queue that must be fired or discarded
if 'using' in kwargs:
transaction.set_dirty(using=kwargs['using'])
else:
transaction.set_dirty()
_get_task_queue().append((self, args, kwargs))
else:
apply_async_orig = super(PostTransactionTask, self).apply_async
return apply_async_orig(*args, **kwargs)

connection = get_connection()
if connection.in_atomic_block and eager_transaction:
_get_task_queue().append((self, args, kwargs))
else:

connection = get_connection()
if connection.in_atomic_block and eager_transaction:
_get_task_queue().append((self, args, kwargs))
else:
return self.original_apply_async(*args, **kwargs)
return self.original_apply_async(*args, **kwargs)

def _discard_tasks(**kwargs):
"""Discards all delayed Celery tasks.
Expand All @@ -153,13 +135,7 @@ def _send_tasks(**kwargs):
queue = _get_task_queue()
while queue:
tsk, args, kwargs = queue.pop(0)
if django.VERSION < (1, 6):
apply_async_orig = tsk.original_apply_async
if celery_eager:
apply_async_orig = transaction.autocommit()(apply_async_orig)
apply_async_orig(*args, **kwargs)
else:
tsk.original_apply_async(*args, **kwargs)
tsk.original_apply_async(*args, **kwargs)


# A replacement decorator.
Expand Down
Loading

0 comments on commit 4285be5

Please sign in to comment.