sysid / sse-starlette

BSD 3-Clause "New" or "Revised" License
505 stars 36 forks source link

update fastapi example to use conditional yielding endpoint #13

Closed justindujardin closed 3 years ago

justindujardin commented 3 years ago

Hi, thanks for the nice library :wave:

I have a FastAPI endpoint that is similar to your example, but only yields when there is new data. As a consequence your AppStatus check does not force my endpoint to close, because there is no yielded item to get into the codepath that checks AppStatus.

I updated your fastapi example to reflect this use-case and added a third task to run_until_first_complete that checks the uvicorn exit status at a regular interval.

sysid commented 3 years ago

Hi justindujardin, thanks for your input and sorry for the late reply! I am pretty busy currently. However, I see the merit of your reasoning. I will give it a more thorough check asap when I have a little more time. Christmas might be a good opportunity here.