Thread safety in Solara when DB is involved

I'm building a Solara app where some operations act on the local DB. For example (and where I'm running into issues), a user can upload a file (via solara.FileDrop). On upload, I create a DB entry from the content of the file. The UI should refresh and show the name of the file in some other place. The issue is that FileDrop handles on_file on a separate thread. When the UI refreshes and tries to access the DB entry, I get session errors. Has anyone had experience with this?
1 Reply
Edan Bainglass
Edan BainglassOP3mo ago
Solved by avoiding use_memo when populating the UI variable from the DB object. I suppose one thread trying to read the value cached on another thread when that value is a DB object is the cause of the problem.

Did you find this page helpful?