From 64a09ef2511cc3f4566cae1fd394c4168a1aa347 Mon Sep 17 00:00:00 2001 From: DM Date: Tue, 10 Feb 2026 10:21:46 -0300 Subject: [PATCH] =?UTF-8?q?=F0=9F=93=9D=20Fix=20StreamingResponse=20doc=20?= =?UTF-8?q?example=20to=20actually=20stream?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add `await asyncio.sleep(1)` to the async generator example so it yields control back to the event loop between chunks, demonstrating actual streaming behavior instead of returning all chunks at once. Closes #14680 --- docs_src/custom_response/tutorial007_py39.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/docs_src/custom_response/tutorial007_py39.py b/docs_src/custom_response/tutorial007_py39.py index e2a53a2119..6d4ed22efd 100644 --- a/docs_src/custom_response/tutorial007_py39.py +++ b/docs_src/custom_response/tutorial007_py39.py @@ -1,3 +1,5 @@ +import asyncio + from fastapi import FastAPI from fastapi.responses import StreamingResponse @@ -6,6 +8,7 @@ app = FastAPI() async def fake_video_streamer(): for i in range(10): + await asyncio.sleep(1) yield b"some fake video bytes"