Mesop and Async Architecture #1299
Replies: 2 comments
-
Please correct me if I'm wrong, I've been debating with Gemini Pro 2.5 which has knowledge on the internal version of Mesop that is out of date and/or has features that hadn't made it to the public release. When a page function is processed as a client hits the associated path, it renders it in a thread set up by the engine behind Mesop, Starlette. So, an I/O bound task that isn't handled asynchronously won't block or prevent other tasks from other client sessions. It will however continue to hold that thread which might exhaust the thread pool. Is that all correct? What might be a more supported way to load data when a page is loaded from a source that could be I/O bound? It's meant to handle what data to load based on a URI parameter and I don't think making a user start another event like a generic load button would be an appropriate solution. |
Beta Was this translation helpful? Give feedback.
-
Yeah, what you're saying sounds generally right. In terms of how to best support this issue of loading data in the background, I wonder if you can switch to the web sockets mode, which is generally better performance-wise. If you have to use the normal SSE mode, then I think it could depend on your use case? How much data are you loading? How many servers/instances are you running? Do you plan to load all the data into memory? |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Does Mesop have any async wrapping magic behind the scenes per Session for potentially blocking events? Example would be a page that requests data from a data base when loaded.
The on_load page event does not currently support real asyncio async functions due to
mesop/server/server.py - line: 173
assuming it's dealing with a standard generator to be iterated over. Async functions can't be iterated in that way directly.So, if it is called as a standard function that could be blocked by I/O, would it block the entire Mesop engine? Just the session? Just that page?
I know some events do support calling async functions, but most of them require user input directly and not when the page is loaded.
Beta Was this translation helpful? Give feedback.
All reactions