all
I am using flask and I am searching for a way to display eventually in a table the celery job status. I have come up with a solution that is only working half way. I have mongodb running as my backend_result I thought I could just query the db for the status. Unfortunately it this never tells of pending task only jobs that were successful or failed, so if there were to be a long running task you would not know that the job was pending.
Is there any solution to get all the real time task status.
@app.route('/process/')
def process():
result = add.delay()
return 'async request sent'
@app.route('/job_status')
def job_status():
db_coll = 'flask_app_job_results'
job_status = (mongo.db[db_coll].find({}, {'status':1, '_id':1})).sort('date',pymongo.ASCENDING)
job_status_list = []
for r in job_status:
try:
job_status_list.append(r['status'])
except:
app.logger.info('status key value not found in mongoDB')
app.logger.info('in job status the jobs are {}'.format(job_status_list))
return str(job_status_list)
@celery.task(name='app.add')
def add():
time.sleep(60)
num = 5 + 5