Multithreading in Trame #453
-
Hi! I'm trying to create a Trame App that, on clicking on a "Run" button, executes a long blocking call to a 3rd party library (some computations). What is the best way to implement it? I tried to use asyncio, but I cannot reload a web page with it (it hangs in that call). I tried to run this long call in a separate thread, but I also want to update the state from that thread to change UI (e.g. to update a label/button text, etc). That does not work - I see no changes in the UI until I reload the page. |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 3 replies
-
You indeed need a separate thread for the blocking side, then you need to have some monitoring async task to keep the UI to update. |
Beta Was this translation helpful? Give feedback.
-
Also don't forget about that section of the getting started guide. |
Beta Was this translation helpful? Give feedback.
-
Hi! I am facing a similar problem. I would like to run trame in a second thread but I would like to run trame in a second thread but I can't get it. Reading your answers I tried to run it with:
But I didn't get any results, could you please provide some kind of example? |
Beta Was this translation helpful? Give feedback.
You indeed need a separate thread for the blocking side, then you need to have some monitoring async task to keep the UI to update.
Basically leveraging those 2 entries.