celery/celery — pull request #816 by steeve (2012-06-21 15:47:26+00:00)
Title: Dynamic tasks for dynamic pipelines

So I submit to you dynamic tasks.

Subtasks returned by dynamic tasks are executed right after the first
task executes. As if they were in a chain.
You can also return chains and chords, and they will be properly inserted.

This allows you to design a pipeline that can be completely dynamic, while
benefiting from Celery's powerful idioms (subtasks, chains, chords...).

Usage example:
```
from celery import task
from celery.contrib.dynamic import dynamic_task

@task
@dynamic_task
def one(i):
if i > 3:
return two.s(i)
return i + 1

@task
@dynamic_task
def two(i):
return i + 2

def test():
one.delay(2) # will run: one.s(2) => 3
one.delay(5) # will run: one.s(5) | two.s() => 7
```