Flask: How to do server side cleanup when session expires?
I have some objects allocated and maintained on the server side throughout my session. How can I make sure they are cleared after the session ends?
Is there support for this in Flask, or some kind of Flask extension?
It looks to me like you are creating objects, not storing them anywhere, just storing them in memory.
If so, then the garbage collector will automatically clean them up: just clean up all references to them, "forget about them" if you like. If you cannot access them yourself, they will be cleared.
If you want to be explicit, use a scheduler (maybe http://docs.python.org/2/library/sched.html ) and create a task calculated when the session expires. When the task is running, make sure that the session is really no longer needed and destroy your objects.