This is a pre-production deployment of Warehouse, however changes made here WILL affect the production instance of PyPI.
Latest Version Dependencies status unknown Test status unknown Test coverage unknown
Project Description

django_transaction_barrier provides a barrier-like abstraction for transactions. A Django application developer can use a “transaction barrier” to spawn a task within a transaction and guarantee that the task blocks until it’s able to access the updates made in the transaction. django_transaction_barrier is designed with Celery in mind and provides a Celery task base class. Using the base class it’s easy to write code that atomically modifies the database and spawns a Celery task that executes after the transaction commits.

Installation

Install from source or use pip:

pip install django_transaction_barrier

and add “django_transaction_barrier” to INSTALLED_APPS in settings.py:

INSTALLED_APPS = (
    'django_transaction_barrier',
    ...
)

Usage

from celery import task
from django.db import transaction
from django_transaction_barrier.celery import TransactionBarrierTask

@task(base=TransactionBarrierTask)
def do_something_task(model_id):
  value = Model.objects.get(id=model_id).value
  ...

@transaction.atomic
def kick_off_task(model, value):
    model.value = value
    do_something_task.apply_async_with_barrier(args=(model.id,))
    model.save()

Details

If an application spawns an asynchronous TransactionBarrierTask the task is guaranteed to execute eventually (assuming a durable task queue) after the transaction commits. If the transaction aborts, the task raises a TransactionAborted exception and does not execute. In autocommit mode (i.e., “outside of a transaction”) TransactionBarrierTasks behave like normal Celery tasks.

If an application synchrnously executes a TransactionBarrierTask (e.g., with Celery eager mode) within a transaction, the task executes immediately without waiting for the transaction to commit.

Implementation

django_transaction_barrier implements transaction barriers using row insertion to signify a committed transaction and some DB-specifc logic to detect an abort.

Tests

docker build -t tests . && docker run tests

TODO

  • Add support for a mysql backend.
Release History

Release History

0.3

This version

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.2

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.1

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

Download Files

Download Files

TODO: Brief introduction on what you do with files - including link to relevant help section.

File Name & Checksum SHA256 Checksum Help Version File Type Upload Date
django-transaction-barrier-0.3.tar.gz (7.6 kB) Copy SHA256 Checksum SHA256 Source Feb 23, 2015

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS HPE HPE Development Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting