Release: SpiffWorkQueue 0.1.0
Here is another initial release: SpiffWorkQueue is an asynchronous, multi-threaded queue. The following example shows how to execute two tasks in parallel. In the example, each task consists of a sequence of two actions:
from SpiffWorkQueue import WorkQueue, Sequence, Action
class MyAction(Action):
def __init__(self, name):
Action.__init__(self, name)
def execute(self, lock, global_context, context):
print "Hello world"
queue = WorkQueue()
actions1 = [MyAction("one"), MyAction("two")]
actions2 = [MyAction("three"), MyAction("four")]
queue.enqueue(Sequence(actions = actions1))
queue.enqueue(Sequence(actions = actions2))
queue.start()
while queue.get_length() > 0:
pass
queue.shutdown()
