Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"Connection closed" Event listener #8094

Closed
mberco-quandl opened this issue Apr 22, 2024 · 4 comments
Closed

"Connection closed" Event listener #8094

mberco-quandl opened this issue Apr 22, 2024 · 4 comments

Comments

@mberco-quandl
Copy link

mberco-quandl commented Apr 22, 2024

  • [Yes] I have searched to see if a similar issue already exists.

Is your feature request related to a problem? Please describe.
No clear way to handle storage leaks that arise when a file exists in Gradio temp storage and a user closes the connection. If running Gradio UI on a docker container disk storage is limited and introducing this leak can cause issues quickly.

Describe the solution you'd like
An event trigger for connection closed. This would allow the server to cleanup temp files associate with that specific connection that don't need to be preserved.

Additional context
Thank you!

@freddyaboulton
Copy link
Collaborator

Hi @mberco-quandl ! There already is such an event! It is the unload event. It is triggered once a user closes their tab. See the docs here

However, gradio can already clean up files periodically for you with the delete_cache parameter of Blocks, Interface, ChatInterface 's init method

image

Will close this in the meantime.

@mberco-quandl
Copy link
Author

I love you guys for making life for frontend noobs a breeze.

@mberco-quandl
Copy link
Author

@freddyaboulton Without inputs to the unload event listener how does one control which files to delete upon terminating the session?

@mberco-quandl
Copy link
Author

mberco-quandl commented Apr 22, 2024

@freddyaboulton for additional clarity I've tried referencing gr.File objects' path using the .value attribute without passing the gr.File in as an input, but it always returns a None. I've tried adding nonlocal flags, other solutions, nothing works as intended yet. Unsure how to a) access and b) pass the session-ID into the function triggered by .unload. Without b) I'm not sure how .unload can be used to manage storage.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants