1

I have a Flask app that generates output based on a query, and gives user multiple options to do more with the output. I need to store the data somewhere between requests and the best solution I found was the multiprocessing.managers (as suggested here: Store large data or a service connection per Flask session). The app will be run on a server continuously.

My question is: after the user disconnects from the app, will the data be discarded over time? If not, how to make sure it does? I don't want to have the server maintain large amounts of data in memory forever. I don't understand very well how Flask and web development works, I hope this makes sense. Thanks.

  • The data would not be cleared automatically, but you can register a call in the manager itself that clears the specific data for the user after they are done. Something like after the user is done with their series of requests, they can call this function and the manager deletes the data for the specific user session from storage. – Charchit Agarwal Jul 10 '22 at 07:50
  • And is there a way to do it automatically, after some time has passed? I don't have a specific end function, I want the user to be able to do as many of each operation as they want. – Peter Poláček Jul 10 '22 at 08:27
  • What I meant was that after the user is done with their requests, they submit another specific request to delete their data from the server. I can't really think of a good, easy way to do that automatically. You would need to store the time along with the data, and need another thread constantly iterating over the data to see if it was fit to delete. But to start a long running thread inside the manager process would mean that other requests to access the manager process would be delayed as well (?). So probably best to structure it around user sending another request to delete their data – Charchit Agarwal Jul 10 '22 at 08:47

0 Answers0