MCPcopy Create free account
hub / github.com/pallets/quart / _stream

Function _stream

src/quart/templating.py:133–157  ·  view source on GitHub ↗
(
    app: Quart, template: Template, context: dict[str, Any]
)

Source from the content-addressed store, hash-verified

131
132
133async def _stream(
134 app: Quart, template: Template, context: dict[str, Any]
135) -> AsyncIterator[str]:
136 await before_render_template.send_async(
137 app,
138 _sync_wrapper=app.ensure_async, # type: ignore[arg-type]
139 template=template,
140 context=context,
141 )
142
143 async def generate() -> AsyncIterator[str]:
144 async for chunk in template.generate_async(context):
145 yield chunk
146 await template_rendered.send_async(
147 app,
148 _sync_wrapper=app.ensure_async, # type: ignore[arg-type]
149 template=template,
150 context=context,
151 )
152
153 # If a request context is active, keep it while generating.
154 if has_request_context():
155 return stream_with_context(generate)()
156 else:
157 return generate()

Callers 2

stream_templateFunction · 0.85
stream_template_stringFunction · 0.85

Calls 3

has_request_contextFunction · 0.85
stream_with_contextFunction · 0.85
generateFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…