So, basically, I want to create a long polling application that uses RQ for the hero. I reviewed this Flask question : going through a background work task (rq, redis) , but that doesn't help.
This is basically what I do.
@app.route('/do_something', methods=['POST']) def get_keywords(): data_json = json.loads(request.data) text = urllib.unquote(data_json["sentence"]) job = q.enqueue(keyword_extraction.extract, text) return job.key @app.route('/do_something/<job_id>', methods=['GET']) def get_keywords_results(job_id): job = Job().fetch(job_id) if(not job.is_finished): return "Not yet", 202 else: return str(job.result)
Nothing was invented, so when a POST request arrives, it will queue the job and return job_id back to the user, and then the user will use the key to continue polling the result. However, I cannot get this to work, since this line Job().fetch(job_id) returns
NoRedisConnectionException: Could not resolve a Redis connection.
Any help would be really appreciated.
source share