Flask: How to do server side cleanup when session expires?
1 answer
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.
0
source to share