HTTPS clone URL
Subversion checkout URL
Python queue management and code deferring
Fetching latest commit…
Cannot retrieve the latest commit at this time
|Failed to load latest commit information.|
====== 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.