How does State clean up and do state objects persist in memory after a user closes their window? #7227
Closed
1 task done
Labels
bug
Something isn't working
Describe the bug
This is a general question / bug I'm wondering about session States in gradio.
I'm trying to detect when a user's session exists (related to clean up tasks: e.g. #3950 and #4016).
This led me to trying to use the State of the session to store data but when testing I noticed that seems garbage collection of session states do no occur until the server is closed. Namely if I give a
gr.State
a class with a__del__
function, this will not get triggered until the server is closes for all sessions.How is gradio handling the clean up of session states and are they cleared from memory when users close the window?
Thank you for the support.
Have you searched existing issues? 🔎
Reproduction
Screenshot
No response
Logs
Running the sample script, opening a browser window and refreshing twice gives:
Closing the server with
ctrl+c
then produces (hangs after first ctrl+c):Note: I would typically expect the Destructor to get called every refresh, but this is not the case?
System Info
Python 3.10.13 >>> import gradio >>> gradio.__version__ '4.16.0'
Severity
I can work around it
The text was updated successfully, but these errors were encountered: