Skip to main content

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

NameTypeDescription
generator_or_functionIterator[AnyStr]The generator or iterator to be wrapped with the current request context.

Returns

TypeDescription
Iterator[AnyStr]An iterator that wraps the original generator, ensuring the request context remains active during iteration.