-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
Add support for async generators in write_stream
#8161
Comments
I want this async support too to use |
@evertoncolling Thanks for the suggestion. We are considering adding this natively to import asyncio
from typing import AsyncGenerator
import streamlit as st
async def async_generator():
yield "hello"
await asyncio.sleep(2)
yield "world"
def to_sync_generator(async_gen: AsyncGenerator):
while True:
try:
yield asyncio.run(anext(async_gen))
except StopAsyncIteration:
break
st.write_stream(to_sync_generator(async_generator())) |
This seem to work for 1 step and then break immediately. |
@FilippTrigub do you have more information on how it breaks? Is there any kind of error? |
Checklist
Summary
Add support for
async_generator
inwrite_stream
. This allows to stream data from async requests in Streamlit.Why?
Today I can only stream data from synchronous HTTP clients while using
write_stream
in Streamlit.How?
Add support for
async_generator
inwrite_stream
.Additional Context
No response
The text was updated successfully, but these errors were encountered: