Python Flask running background functions returning values
This may not answer your question directly, as I have a similar question about using Flask with 'background' data.
I just wanted to make sure you know about ROS.... ROS.org.  It has tools to help with what you are doing.
Check out Flask-Script as well, though I'm not sure it will solve your problem.  I'm currently using an SQLite DB to pass data between my applications (Flask for user status/interaction, a program that reads the hardware into the DB, and another program that makes decisions based on hardware inputs..) but my system is slow, 1Hz update rate is plenty.
I have a Python Flask application that I'm planning to use as a monitor for a robot that drives around (using Player/Stage). Now I'm able to connect with the robot and request information and so on.
Player/Stage sends data about the position of the robot every time interval. I'm stuck with the following:

The information about the position should be displayed in HTML, I was thinking about a jQuery POST that requests the position every 500ms and then updates the html (easy). Is there a better solution?
Player/Stage also sends the actual location estimation of the robot, I want a background process that can save the data so I can display it (like number 1), I don't see how a cerely background job saves the information it calculates. How can I display the output of a background job and send it to the user (html/json)?

I actually need to manage a couple of background jobs and let them quit depending on the output of another background job. So for example, when the robot drives to a specific point, I quit a job, start another, display its data to the user, and so on.
I hope my explanation was helpful, I'm looking for advice, code samples and anything related.
Regards,