How to make make run the subtasks for periodic task with Celery?
<p>I would like to create <em>periodic</em> task which makes query to database, get's data from data provider, makes some API requests, formats documents and sends them using another API. </p>

<p>Result of the previous task should be chained to the next task. I've got from the documentation that I have to use <strong>chain</strong>, <strong>group</strong> and <strong>chord</strong> in order to organise chaining. </p>

<p>But, what else I've got from the documentation: don't run subtask from the task, because it might be the reason of deadlocks. </p>

<p>So, the question is: how to run subtasks inside the periodic task?</p>

<pre><code>@app.task(name='envoy_emit_subscription', ignore_result=False)
def emit_subscriptions(frequency):
# resulting queryset is the source for other tasks
    return Subscription.objects.filter(definition__frequency=1).values_list('pk', flat=True)



@app.task(name='envoy_query_data_provider', ignore_result=False)
def query_data_provider(pk):
    # gets the key from the chain and returns received data
    return "data"


@app.task(name='envoy_format_subscription', ignore_result=False)
def format_subscription(data):
    # formats documents
    return "formatted text"


@app.task(name='envoy_send_subscription', ignore_result=False)
def send_subscription(text):
    return send_text_somehow(text)
</code></pre>

<p>Sorry for the noob question, but I'm a noob in Celery, indeed.</p>

<p>Something like this maybe?</p>

<pre><code>import time

while True:
    my_celery_chord()
    time.sleep(...)
</code></pre>

python celery