(
app: Quart, template: Template, context: dict[str, Any]
)
| 131 | |
| 132 | |
| 133 | async 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() |
no test coverage detected
searching dependent graphs…