- Sort Score
- Num 10 results
- Language All
Results 31 - 40 of 199 for yielded (0.06 seconds)
-
docs/en/docs/advanced/events.md
The first thing to notice, is that we are defining an async function with `yield`. This is very similar to Dependencies with `yield`. {* ../../docs_src/events/tutorial003_py39.py hl[14:19] *} The first part of the function, before the `yield`, will be executed **before** the application starts. And the part after the `yield` will be executed **after** the application has finished. ### Async Context Manager { #async-context-manager }Created: Sun Dec 28 07:19:09 GMT 2025 - Last Modified: Wed Dec 17 20:41:43 GMT 2025 - 7.9K bytes - Click Count (0) -
docs/pt/docs/advanced/events.md
A primeira coisa a notar é que estamos definindo uma função assíncrona com `yield`. Isso é muito semelhante a Dependências com `yield`. {* ../../docs_src/events/tutorial003_py39.py hl[14:19] *} A primeira parte da função, antes do `yield`, será executada **antes** de a aplicação iniciar. E a parte posterior ao `yield` será executada **depois** de a aplicação ter terminado.Created: Sun Dec 28 07:19:09 GMT 2025 - Last Modified: Wed Dec 17 20:41:43 GMT 2025 - 8.8K bytes - Click Count (0) -
tests/test_dependency_after_yield_raise.py
class CustomError(Exception): pass def catching_dep() -> Any: try: yield "s" except CustomError as err: raise HTTPException(status_code=418, detail="Session error") from err def broken_dep() -> Any: yield "s" raise ValueError("Broken after yield") app = FastAPI() @app.get("/catching") def catching(d: Annotated[str, Depends(catching_dep)]) -> Any:
Created: Sun Dec 28 07:19:09 GMT 2025 - Last Modified: Wed Dec 17 21:25:59 GMT 2025 - 1.7K bytes - Click Count (0) -
tests/test_dependency_contextvars.py
client = TestClient(app) def test_dependency_contextvars(): """ Check that custom middlewares don't affect the contextvar context for dependencies. The code before yield and the code after yield should be run in the same contextvar context, so that request_state_context_var.reset(contextvar_token). If they are run in a different context, that raises an error. """
Created: Sun Dec 28 07:19:09 GMT 2025 - Last Modified: Wed Dec 17 21:25:59 GMT 2025 - 1.5K bytes - Click Count (0) -
docs/de/docs/advanced/events.md
Das Erste, was auffällt, ist, dass wir eine asynchrone Funktion mit `yield` definieren. Das ist sehr ähnlich zu Abhängigkeiten mit `yield`. {* ../../docs_src/events/tutorial003_py39.py hl[14:19] *} Der erste Teil der Funktion, vor dem `yield`, wird ausgeführt **bevor** die Anwendung startet. Und der Teil nach `yield` wird ausgeführt, **nachdem** die Anwendung beendet ist.Created: Sun Dec 28 07:19:09 GMT 2025 - Last Modified: Wed Dec 17 20:41:43 GMT 2025 - 9.5K bytes - Click Count (0) -
docs/ko/docs/advanced/events.md
새로운 버전을 시작해야 하거나, 그냥 실행을 멈추고 싶을 수도 있습니다. 🤷 /// ### Lifespan 함수 먼저 주목할 점은, `yield`를 사용하여 비동기 함수(async function)를 정의하고 있다는 것입니다. 이는 `yield`를 사용한 의존성과 매우 유사합니다. {* ../../docs_src/events/tutorial003.py hl[14:19] *} 함수의 첫 번째 부분, 즉 `yield` 이전의 코드는 애플리케이션이 시작되기 **전에** 실행됩니다. 그리고 `yield` 이후의 부분은 애플리케이션이 완료된 후 **나중에** 실행됩니다. ### 비동기 컨텍스트 매니저 함수를 확인해보면, `@asynccontextmanager`로 장식되어 있습니다.Created: Sun Dec 28 07:19:09 GMT 2025 - Last Modified: Sat Oct 11 17:48:49 GMT 2025 - 9.2K bytes - Click Count (0) -
tests/test_exception_handlers.py
} ) client = TestClient(app) def raise_value_error(): raise ValueError() def dependency_with_yield(): yield raise_value_error() @app.get("/dependency-with-yield", dependencies=[Depends(dependency_with_yield)]) def with_yield(): ... @app.get("/http-exception") def route_with_http_exception(): raise HTTPException(status_code=400)
Created: Sun Dec 28 07:19:09 GMT 2025 - Last Modified: Tue Dec 03 22:37:12 GMT 2024 - 2.4K bytes - Click Count (0) -
docs/zh/docs/advanced/events.md
可能你需要启动一个新版本,或者你只是你厌倦了运行它。 🤷 /// ## 生命周期函数 首先要注意的是,我们定义了一个带有 `yield` 的异步函数。这与带有 `yield` 的依赖项非常相似。 ```Python hl_lines="14-19" {!../../docs_src/events/tutorial003.py!} ``` 这个函数在 `yield`之前的部分,会在应用启动前执行。 剩下的部分在 `yield` 之后,会在应用完成后执行。 ## 异步上下文管理器 如你所见,这个函数有一个装饰器 `@asynccontextmanager` 。 它将函数转化为所谓的“**异步上下文管理器**”。 ```Python hl_lines="1 13" {!../../docs_src/events/tutorial003.py!} ```Created: Sun Dec 28 07:19:09 GMT 2025 - Last Modified: Sat Oct 11 17:48:49 GMT 2025 - 7K bytes - Click Count (0) -
docs_src/dependencies/tutorial008_py39.py
dep_a = generate_dep_a() try: yield dep_a finally: dep_a.close() async def dependency_b(dep_a=Depends(dependency_a)): dep_b = generate_dep_b() try: yield dep_b finally: dep_b.close(dep_a) async def dependency_c(dep_b=Depends(dependency_b)): dep_c = generate_dep_c() try: yield dep_c finally:
Created: Sun Dec 28 07:19:09 GMT 2025 - Last Modified: Wed Dec 17 20:41:43 GMT 2025 - 455 bytes - Click Count (0) -
tests/test_dependency_class.py
class CallableGenDependency: def __call__(self, value: str) -> Generator[str, None, None]: yield value class AsyncCallableDependency: async def __call__(self, value: str) -> str: return value class AsyncCallableGenDependency: async def __call__(self, value: str) -> AsyncGenerator[str, None]: yield value class MethodsDependency: def synchronous(self, value: str) -> str:Created: Sun Dec 28 07:19:09 GMT 2025 - Last Modified: Wed Dec 17 21:25:59 GMT 2025 - 4.4K bytes - Click Count (0)