mirror of https://github.com/tiangolo/fastapi.git
docs: add async usage tip for clarity
This commit is contained in:
parent
5a57c67b8e
commit
762326eb96
|
|
@ -177,10 +177,10 @@ def read_item(item_id: int, q: Union[str, None] = None):
|
||||||
<details markdown="1">
|
<details markdown="1">
|
||||||
<summary>Or use <code>async def</code>...</summary>
|
<summary>Or use <code>async def</code>...</summary>
|
||||||
|
|
||||||
> **Tip:** Use `async def` when performing I/O-bound operations to fully benefit from FastAPI's asynchronous performance.
|
!!! tip
|
||||||
**Tip**: Use `async def` only when your code performs non-blocking I/O
|
Use `async def` only when your code performs non-blocking I/O,
|
||||||
(e.g. database calls, external APIs). For CPU-bound or blocking code,
|
such as database queries or external API calls.
|
||||||
prefer `def` to avoid performance issues.
|
|
||||||
|
|
||||||
|
|
||||||
```Python hl_lines="9 14"
|
```Python hl_lines="9 14"
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue