docs and docs_src: add clarifing comment about async code

This commit is contained in:
KrzysztofCzapla 2025-11-11 21:38:11 +01:00
parent 581d111f86
commit a807b1bf09
1 changed files with 4 additions and 2 deletions

View File

@ -105,9 +105,11 @@ We will create the database tables when the application starts.
{* ../../docs_src/sql_databases/tutorial001_an_py310.py ln[35:41] hl[35:38,41] *}
Here we create the tables on an application startup using the `lifespan` function.
Here we create the tables on an application startup using the async `lifespan` function.
You can read more about it in the [Lifespan Events](../advanced/events.md){.internal-link target=_blank}.
Since `create_db_and_tables()` is synchronous, we run it inside `asyncio.to_thread()` to prevent blocking the event loop.
You can read more about the application startup in the [Lifespan Events](../advanced/events.md){.internal-link target=_blank}.
For production you would probably use a migration script that runs before you start your app. 🤓