I am using flask in an application that does some long-running computations. I've successfully offloaded the compute-intensive code to an rq worker with this code
job = q.enqueue(run_simulation)
This is followed by the following code:
while not job.is_finished:
time.sleep(1)
job.refresh()
print(job.meta)
the run_simulation
code updates its progress using job.meta as follows:
while still_stuff_to_do:
job = get_current_job()
job.meta['progress'] = percent_complete
job.save_meta()
do_more_stuff...
Everything described so far works as intended. In the console, I get the percent_complete printed out once per second.
The user experience I would like to have is that, once the compute-intensive job is kicked off, I'd like to pop up a modal dialog with a progress bar (using bootstrap) and a cancel button. The progress bar should update the progress indicator once per second. I'd like suggestions for a simple approach to solving this. Specifically, I don't understand what the execution model should be.