I have a long task that goes off into a python-rq worker queue.
@cache.cached(timeout=2592000)
@app.route('/as/<keyword>', methods=['GET'])
@db_session
def auto_suggest(keyword):
job = q.enqueue(find_keyword, keyword)
while not job:
time.sleep(1)
return jsonify(word=job)
I'm using flask-cache
to try and save the result as its a calculation that only needs to be run once a week at most, once a month is sufficient as well.
The problem I am having is when this runs, it caches the failed response, and not the actual solution.
Any other way to do this? Or suggestion in how I should approach this?