Flask Celery update_state from inside another function
<p>I'd like to update the state of my Celery task from another function. Here's what I have now:</p>

<h1>The Route</h1>

<pre><code>@app.route('/my-long-function', methods=['POST'])
def my_long_function():

    param1 = request.form['param1']
    param2 = request.form['param2']

    task = outside_function.delay(param1, param2)

    return task.id
</code></pre>

<h1>Celery Task - starts some_python_script.handle in the background</h1>

<pre><code>@celery.task(name='outside_function')
def outside_function(param1, param2):
    with app.app_context():
        some_python_script.handle(param1, param2)
</code></pre>

<h1>some_python_script.handle:</h1>

<pre><code>def handle(param1, param2):
    param1 + param2
    # many, many different things
</code></pre>

<p>Ideally, I'd like to be able to self.update_state the celery task so that I can easily request its status from my app, like so:</p>

<h1>some_python_script.handle (ideally):</h1>

<pre><code>def handle(param1, param2):
    param1 + param2
    # many, many different things
    self.outside_function.update_state('PROGRESS', meta = {'status':'progressing'})
</code></pre>

<h1>check progress (ideally):</h1>

<pre><code>@app.route('/status/&lt;task_id&gt;')
def taskstatus(task_id):
    task = outside_function.AsyncResult(task_id)
    response = {
    'state': task.state,
    'id': task.id,
    'status' : task.status,
    }

    return jsonify(response)
</code></pre>

<p>Or something similar. Would appreciate any help, I'm very new to Celery!</p>