-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Make StreamingResponse compatible with normal iterators #461
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
Conversation
starlette/concurrency.py
Outdated
| raise _StopSyncIteration | ||
|
|
||
|
|
||
| async def iterator_to_async(iterator: Iterator) -> AsyncGenerator: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about iterate_in_threadpool to mirror run_in_threadpool.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great idea. I struggled a lot to name it and wasn't quite convinced either.
|
Do we strictly need the |
|
Can we not catch StopIteration directly? |
|
|
|
Because Actually, now that I think of it, using a class would still need the indirection, as we need an exception that is propagated up/out even when run inside of |
|
👍 Released as prerelease version 0.12.0b3 |
|
Awesome! Thanks! 🎉 🚀 |
Make
StreamingResponsecompatible with normal iterators.Continuing from #457, #457 (comment)
I also removed the mention to
iterator_to_asyncfrom the docs, only mention that it supports both async and normal generators.Let's see what do you think about this one and then I'll take a stab at that 😄