- Sort Score
- Num 10 results
- Language All
Results 1 - 10 of 12 for asynccontextmanager (0.08 seconds)
-
docs_src/events/tutorial003_py310.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()
Created: Sun Apr 05 07:19:11 GMT 2026 - Last Modified: Thu Feb 12 13:19:43 GMT 2026 - 569 bytes - Click Count (0) -
docs_src/app_testing/tutorial004_py310.py
from contextlib import asynccontextmanager from fastapi import FastAPI from fastapi.testclient import TestClient items = {} @asynccontextmanager async def lifespan(app: FastAPI): items["foo"] = {"name": "Fighters"} items["bar"] = {"name": "Tenders"} yield # clean up items items.clear() app = FastAPI(lifespan=lifespan) @app.get("/items/{item_id}") async def read_items(item_id: str):Created: Sun Apr 05 07:19:11 GMT 2026 - Last Modified: Thu Feb 12 13:19:43 GMT 2026 - 1.2K bytes - Click Count (0) -
fastapi/concurrency.py
from collections.abc import AsyncGenerator from contextlib import AbstractContextManager from contextlib import asynccontextmanager as asynccontextmanager from typing import TypeVar import anyio.to_thread 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
Created: Sun Apr 05 07:19:11 GMT 2026 - Last Modified: Wed Dec 17 21:25:59 GMT 2025 - 1.5K bytes - Click Count (0) -
docs/en/docs/advanced/events.md
And the part after the `yield` will be executed **after** the application has finished. ### Async Context Manager { #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_py310.py hl[1,13] *}Created: Sun Apr 05 07:19:11 GMT 2026 - Last Modified: Thu Mar 05 18:13:19 GMT 2026 - 7.8K bytes - Click Count (0) -
docs/de/docs/advanced/events.md
Und der Teil nach `yield` wird ausgeführt, **nachdem** die Anwendung beendet ist. ### Asynchroner Kontextmanager { #async-context-manager } Wie Sie sehen, ist die Funktion mit einem `@asynccontextmanager` versehen. Dadurch wird die Funktion in einen sogenannten „**asynchronen Kontextmanager**“ umgewandelt. {* ../../docs_src/events/tutorial003_py310.py hl[1,13] *}Created: Sun Apr 05 07:19:11 GMT 2026 - Last Modified: Thu Mar 19 17:58:09 GMT 2026 - 9.4K bytes - Click Count (0) -
docs/tr/docs/advanced/events.md
`yield`’den sonraki kısım ise, uygulama işini bitirdikten **sonra** çalışır. ### Async Context Manager { #async-context-manager } Bakarsanız, fonksiyon `@asynccontextmanager` ile dekore edilmiş. Bu da fonksiyonu "**async context manager**" denen şeye dönüştürür. {* ../../docs_src/events/tutorial003_py310.py hl[1,13] *}Created: Sun Apr 05 07:19:11 GMT 2026 - Last Modified: Fri Mar 20 07:53:17 GMT 2026 - 8.3K bytes - Click Count (0) -
docs/pt/docs/advanced/events.md
E a parte posterior ao `yield` será executada **depois** de a aplicação ter terminado. ### Gerenciador de contexto assíncrono { #async-context-manager } Se você verificar, a função está decorada com um `@asynccontextmanager`. Isso converte a função em algo chamado "**gerenciador de contexto assíncrono**". {* ../../docs_src/events/tutorial003_py310.py hl[1,13] *}Created: Sun Apr 05 07:19:11 GMT 2026 - Last Modified: Thu Mar 19 18:20:43 GMT 2026 - 8.7K bytes - Click Count (0) -
docs/zh-hant/docs/advanced/events.md
{* ../../docs_src/events/tutorial003_py310.py hl[14:19] *} 函式在 `yield` 之前的部分,會在應用啟動前先執行。 `yield` 之後的部分,會在應用結束後再執行。 ### 非同步內容管理器(Async Context Manager) { #async-context-manager } 你會看到這個函式被 `@asynccontextmanager` 裝飾。 它會把函式轉換成所謂的「**非同步內容管理器(async context manager)**」。 {* ../../docs_src/events/tutorial003_py310.py hl[1,13] *} Python 中的**內容管理器(context manager)**可以用在 `with` 陳述式中,例如 `open()` 可以作為內容管理器使用: ```PythonCreated: Sun Apr 05 07:19:11 GMT 2026 - Last Modified: Fri Mar 20 17:05:38 GMT 2026 - 7.2K bytes - Click Count (0) -
docs/es/docs/advanced/events.md
Y la parte después del `yield` será ejecutada **después** de que la aplicación haya terminado. ### Async Context Manager { #async-context-manager } Si revisas, la función está decorada con un `@asynccontextmanager`. Eso convierte a la función en algo llamado un "**async context manager**". {* ../../docs_src/events/tutorial003_py310.py hl[1,13] *}Created: Sun Apr 05 07:19:11 GMT 2026 - Last Modified: Thu Mar 19 18:15:55 GMT 2026 - 8.4K bytes - Click Count (0) -
docs/fr/docs/advanced/events.md
Et la partie après le `yield` sera exécutée **après** que l'application a terminé. ### Gestionnaire de contexte asynchrone { #async-context-manager } Si vous regardez, la fonction est décorée avec `@asynccontextmanager`. Cela convertit la fonction en quelque chose appelé un « **gestionnaire de contexte asynchrone** ». {* ../../docs_src/events/tutorial003_py310.py hl[1,13] *}Created: Sun Apr 05 07:19:11 GMT 2026 - Last Modified: Thu Mar 19 18:37:13 GMT 2026 - 9.1K bytes - Click Count (0)