- Sort Score
- Result 10 results
- Languages All
Results 1 - 8 of 8 for asynccontextmanager (0.1 sec)
-
docs_src/events/tutorial003.py
from contextlib import asynccontextmanager from fastapi import FastAPI def fake_answer_to_everything_ml_model(x: float): return x * 42 ml_models = {} @asynccontextmanager async def lifespan(app: FastAPI): # Load the ML model ml_models["answer_to_everything"] = fake_answer_to_everything_ml_model yield # Clean up the ML models and release the resources ml_models.clear()
Registered: Sun Nov 03 07:19:11 UTC 2024 - Last Modified: Tue Mar 07 15:46:00 UTC 2023 - 569 bytes - Viewed (0) -
tests/test_router_events.py
def test_merged_mixed_state_lifespans() -> None: @asynccontextmanager async def lifespan(app: FastAPI) -> AsyncGenerator[None, None]: yield @asynccontextmanager async def router_lifespan(app: FastAPI) -> AsyncGenerator[Dict[str, bool], None]: yield {"router": True} @asynccontextmanager async def sub_router_lifespan(app: FastAPI) -> AsyncGenerator[None, None]:
Registered: Sun Nov 03 07:19:11 UTC 2024 - Last Modified: Sat Aug 24 19:09:52 UTC 2024 - 7.3K bytes - Viewed (0) -
fastapi/concurrency.py
from contextlib import asynccontextmanager as asynccontextmanager from typing import AsyncGenerator, ContextManager, TypeVar import anyio from anyio import CapacityLimiter from starlette.concurrency import iterate_in_threadpool as iterate_in_threadpool # noqa from starlette.concurrency import run_in_threadpool as run_in_threadpool # noqa from starlette.concurrency import ( # noqa run_until_first_complete as run_until_first_complete, )
Registered: Sun Nov 03 07:19:11 UTC 2024 - Last Modified: Mon Dec 25 17:57:35 UTC 2023 - 1.4K bytes - Viewed (0) -
docs/em/docs/tutorial/dependencies/dependencies-with-yield.md
* <a href="https://docs.python.org/3/library/contextlib.html#contextlib.asynccontextmanager" class="external-link" target="_blank">`@contextlib.asynccontextmanager`</a> ๐ โ โ๏ธ **FastAPI** ๐. ๐, FastAPI โ๏ธ ๐ 2๏ธโฃ ๐จโ๐จ ๐. /// ## ๐ฝ ๐ โฎ๏ธ `yield` ๐ผ, ๐ ๐ช โ๏ธ ๐ โ ๐ฝ ๐ & ๐ โซ๏ธ โฎ๏ธ ๐.
Registered: Sun Nov 03 07:19:11 UTC 2024 - Last Modified: Sun Oct 06 20:36:54 UTC 2024 - 8.6K bytes - Viewed (0) -
docs/em/docs/advanced/events.md
```Python hl_lines="14-19" {!../../docs_src/events/tutorial003.py!} ``` ๐ฅ ๐ ๐ข, โญ `yield`, ๐ ๐ ๏ธ **โญ** ๐ธ โถ๏ธ. & ๐ โฎ๏ธ `yield` ๐ ๐ ๏ธ **โฎ๏ธ** ๐ธ โ๏ธ ๐. ### ๐ ๐ ๐จโ๐ผ ๐ฅ ๐ โ , ๐ข ๐ โฎ๏ธ `@asynccontextmanager`. ๐ ๐ ๐ข ๐ ๐ณ ๐ค "**๐ ๐ ๐จโ๐ผ**". ```Python hl_lines="1 13" {!../../docs_src/events/tutorial003.py!} ``` **๐ ๐จโ๐ผ** ๐ ๐ณ ๐ ๐ ๐ช โ๏ธ `with` ๐, ๐ผ, `open()` ๐ช โ๏ธ ๐ ๐จโ๐ผ: ```Python
Registered: Sun Nov 03 07:19:11 UTC 2024 - Last Modified: Sun Oct 06 20:36:54 UTC 2024 - 6.1K bytes - Viewed (0) -
docs/de/docs/advanced/events.md
Und der Teil nach `yield` wird ausgefรผhrt, **nachdem** die Anwendung beendet ist. ### Asynchroner Kontextmanager Wie Sie sehen, ist die Funktion mit einem `@asynccontextmanager` versehen. Dadurch wird die Funktion in einen sogenannten โ**asynchronen Kontextmanager**โ umgewandelt. ```Python hl_lines="1 13" {!../../docs_src/events/tutorial003.py!} ```
Registered: Sun Nov 03 07:19:11 UTC 2024 - Last Modified: Sun Oct 06 20:36:54 UTC 2024 - 9.1K bytes - Viewed (0) -
docs/pt/docs/advanced/events.md
E a parte posterior do `yield` irรก executar **apรณs** a aplicaรงรฃo ser encerrada. ### Gerenciador de Contexto Assรญncrono Se vocรช verificar, a funรงรฃo estรก decorada com um `@asynccontextmanager`. Que converte a funรงรฃo em algo chamado de "**Gerenciador de Contexto Assรญncrono**". ```Python hl_lines="1 13" {!../../docs_src/events/tutorial003.py!} ```
Registered: Sun Nov 03 07:19:11 UTC 2024 - Last Modified: Sun Oct 06 20:36:54 UTC 2024 - 8.6K bytes - Viewed (0) -
docs/en/docs/advanced/events.md
And the part after the `yield` will be executed **after** the application has finished. ### Async Context Manager If you check, the function is decorated with an `@asynccontextmanager`. That converts the function into something called an "**async context manager**". {* ../../docs_src/events/tutorial003.py hl[1,13] *}
Registered: Sun Nov 03 07:19:11 UTC 2024 - Last Modified: Mon Oct 28 10:36:22 UTC 2024 - 7.6K bytes - Viewed (0)