1

I'm trying to build a REST API with Flask that's supposed to respond based on a statistical model implemented with pandas and numpy. The model is a constant for a set number of days, after which it needs to be updated (reloaded from an object store). My response time needs to be fast, so I thought I can just hold it in memory and do my calculations as needed before responding. While that works standalone, I can't seem to find a way to use this simple architecture in a Flask application.

I have explored using session with session.permanent set to True, but that requires my model to be serialisable. That is non-trivial for my case. I also don't know how to handle permanent_session_lifetime if I take this approach. I presume, I would need to reset this timer? How do I achieve that? Is it as simple as creating a new secret_key?

I also considered using app.config, but there I'm not sure how a model update would be handled in a multi-threaded environment (in production).

suvayu
  • 4,271
  • 2
  • 29
  • 35

0 Answers0