-
I have a large B2B app and am loving stlite for its deployment. Does anyone know a way to handle the following constraints?
In summary, does anyone know how to do a top-level await that would work during vanilla streamlit (like wrapping main in asyncio.run(main)... but which would also work when deployed in stlite? |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 4 replies
-
Hi,
I couldn't get this.
alaik it's not possible on the normal Streamlit now. You mean, you want the full code portability between Streamlit and Stlite when the code contains async & await? |
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
-
Thanks!
In case it is ever helpful, I technically got it working this way:
a) put streamlit version in asyncio.run(my_func())
b) put stlite version in this:
loop = asyncio.get_event_loop()
try:
loop.run_until_complete(my_func())
finally:
loop.close()
<re-render updated widgets>
The problem is the "finally" wouldn't actually wait until "try" completed.
So then the re-render would be missed and you would have to manually re-run
to get the outcomes of the function. Adding a delay made it seem to work.
…On Fri, Oct 18, 2024 at 3:56 PM Yuichiro Tachibana (Tsuchiya) < ***@***.***> wrote:
Thanks, I understood.
I think it's not possible for now.
Let's track this issue on #1173
<#1173> where I will try to
asyncio.run() work on Stlite, which should help this.
—
Reply to this email directly, view it on GitHub
<#1164 (reply in thread)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AEUWJKECPIRBFMPSGWRITZLZ4CIIRAVCNFSM6AAAAABQCSJ3TWVHI2DSMVQWIX3LMV43URDJONRXK43TNFXW4Q3PNVWWK3TUHMYTAOJXHA3TGOA>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
@Norcim133
I'm working on it.
Do you think this helps?
https://31ad5dfc.stlite-sharing-editor.pages.dev/#!ChBzdHJlYW1saXRfYXBwLnB5EswBChBzdHJlYW1saXRfYXBwLnB5ErcBCrQBaW1wb3J0IHN0cmVhbWxpdCBhcyBzdAppbXBvcnQgYXN5bmNpbwoKYXN5bmMgZGVmIGZvbygpOgogICAgc3Qud3JpdGUoIlN0YXJ0IikKICAgIHdpdGggc3Quc3Bpbm5lcigpOgogICAgICAgIGF3YWl0IGFzeW5jaW8uc2xlZXAoMSkKICAgICAgICBzdC53cml0ZSgiQXdhaXRlZCIpCgphc3luY2lvLnJ1bihmb28oKSkK
This is a prototype env.