def long_func(*args, **kwargs):
    i = 0
while True:
    yield i
do_something_here(*args, **kwargs)
i += 1

@task()
def test_yield_task(task_id=None, **kwargs):
    the_progress = 0
for the_progress in long_func(**kwargs):
    cache.set('celery-task-%s' % task_id, the_progress)
Reporting yielded results of long-running Celery task