Skip to main content
This is a pre-production deployment of Warehouse. Changes made here affect the production instance of PyPI (pypi.python.org).
Help us improve Python packaging - Donate today!

Queue management and code deferment

Project Description

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.

Release History

Release History

This version
History Node

0.1.0pre

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS 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