stream_with_context
No overview available.
def stream_with_context(
generator_or_function: Iterator[AnyStr]
) - > Iterator[AnyStr]
Request context is preserved while a generator is consumed. This is useful for streaming responses that need to access request-bound data like session or g.
Parameters
| Name | Type | Description |
|---|---|---|
| generator_or_function | Iterator[AnyStr] | The generator or iterator to be wrapped with the current request context. |
Returns
| Type | Description |
|---|---|
Iterator[AnyStr] | An iterator that wraps the original generator, ensuring the request context remains active during iteration. |