public
Description: Python queue management and code deferring
Homepage:
Clone URL: git://github.com/brosner/engine.git
engine /
name age message
file README Tue Sep 23 21:44:49 -0700 2008 README fix. [brosner]
directory bin/ Wed Sep 24 11:57:14 -0700 2008 Added a test function to test the queue. [brosner]
directory engine/ Sun Nov 23 11:19:17 -0800 2008 Fixes a call to super. Signed-off-by: Brian Ro... [sneeu]
file setup.py Sun Jan 04 01:26:18 -0800 2009 Added a description and long_description to set... [brosner]
README
======
engine
======

What is engine?
===============

engine is a collection of tools for processing a queue. It provides an API to
defer a callable and run it later. engine also provides process helpers to
set up a safe environment for clearing different kind of queues.

How to use engine?
==================

The basic usage of engine is to defer something to execute later. However, the
internals are written in such way to allow for planning. You can plan your
code to use a queue, but a queue doesn't even need to be present. Lets take a
look at an example::

    >>> import engine
    >>> def hello_world():
    ...     print "hello world"
    
    >>> engine.defer(hello_world)
    hello world

As you can see above, the function ``hello_world`` was executed immediately.
This is because, by default, engine will use the ``DummyQueue`` which will
execute the given callable when put on the queue.

If you have a queue such as stompserver, ActiveMQ or any STOMP compliant
queue you can use ``StompQueue``. Lets take a look at an example::

    >>> import engine
    >>> def hello_world():
    ...     print "hello world"
    
    >>> engine.defer(hello_world, queue=engine.StompQueue())

The above code will now defer the call to ``hello_world`` by sending it to the
queue.

You can define the default queue used by engine. To do this you should use
``engine.configure``. Here is an example changing the default queue from
``DummyQueue`` to ``StompQueue``::

    >>> import engine
    >>> engine.configure(queue=engine.StompQueue())

Now all calls to ``engine.defer`` will use the ``StompQueue`` instance.