Code Monkey home page Code Monkey logo

pyramid_transactional_celery's Introduction

Transactional Celery for Pyramid

https://badge.fury.io/py/pyramid_transactional_celery.png https://travis-ci.org/petrilli/pyramid_transactional_celery.png?branch=master https://pypip.in/d/pyramid_transactional_celery/badge.png

A transaction-aware Celery job setup. This is integrated with the Zope transaction package, which implements a full two-phase commit protocol. While it is not designed for anything other than Pyramid, it also does not use any component of Pyramid. It's simply not tested anywhere else.

Features

  • Queues tasks into a thread-local when they are called either using delay or apply_async.
  • If the transaction is aborted, then the tasks will never be called.
  • If the transaction is committed, the tasks will go through their normal apply_async process and be queued for processing.

Limitations

Currently, the code is designed around Celery v3.1, and it is unknown whether it will work with previous versions. I'm more than happy to integrate changes that would make it work with other releases, but since I generally stay on the latest release, it isn't a priority for my own development.

Usage

Using the library is a relatively easy thing to do. First, you'll need to integrate Celery into your Pyramid application, for which I recommend using pyramid_celery. Once that's done, you simply need to start creating your tasks. The big difference is for function-based tasks, you use a different decorator:

from pyramid_transactional_celery import task_tm

@task_tm
def add(x, y):
    """Add two numbers together."""
    return x + y

That's all there is to it. For class-based tasks, you simply need to subclass TransactionalTask instead of Task:

from pyramid_transactional_celery import TransactionalTask

class SampleTask(TransactionalTask):
    """A sample task that is transactional."""
    def run(x, y):
        return x + y

That's it. Bob's your uncle.

pyramid_transactional_celery's People

Contributors

petrilli avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.