Search Options

Results per page
Sort
Preferred Languages
Advance

Results 21 - 30 of 184 for yielded (0.03 sec)

  1. tests/test_dependency_after_yield_streaming.py

                if self.open:
                    yield item
                else:
                    raise ValueError("Session closed")
    
    
    @contextmanager
    def acquire_session() -> Generator[Session, None, None]:
        session = Session()
        try:
            yield session
        finally:
            session.open = False
    
    
    def dep_session() -> Any:
        with acquire_session() as s:
            yield s
    
    
    def broken_dep_session() -> Any:
    Registered: Sun Dec 28 07:19:09 UTC 2025
    - Last Modified: Wed Dec 17 21:25:59 UTC 2025
    - 3.2K bytes
    - Viewed (0)
  2. tests/test_router_events.py

        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]:
            yield
    
        sub_router = APIRouter(lifespan=sub_router_lifespan)
    Registered: Sun Dec 28 07:19:09 UTC 2025
    - Last Modified: Wed Dec 17 21:25:59 UTC 2025
    - 7.3K bytes
    - Viewed (0)
  3. tests/test_dependency_wrapped.py

                async for item in iterate_in_threadpool(func(*args, **kwargs)):
                    yield item
    
            return gen_wrapper
    
        elif inspect.isasyncgenfunction(func):
    
            @wraps(func)
            async def async_gen_wrapper(*args, **kwargs):
                async for item in func(*args, **kwargs):
                    yield item
    
            return async_gen_wrapper
    
        @wraps(func)
    Registered: Sun Dec 28 07:19:09 UTC 2025
    - Last Modified: Wed Dec 17 21:25:59 UTC 2025
    - 11.2K bytes
    - Viewed (0)
  4. docs_src/dependencies/tutorial008_an_py39.py

    from fastapi import Depends
    
    
    async def dependency_a():
        dep_a = generate_dep_a()
        try:
            yield dep_a
        finally:
            dep_a.close()
    
    
    async def dependency_b(dep_a: Annotated[DepA, Depends(dependency_a)]):
        dep_b = generate_dep_b()
        try:
            yield dep_b
        finally:
            dep_b.close(dep_a)
    
    
    async def dependency_c(dep_b: Annotated[DepB, Depends(dependency_b)]):
    Registered: Sun Dec 28 07:19:09 UTC 2025
    - Last Modified: Sat Mar 18 12:29:59 UTC 2023
    - 521 bytes
    - Viewed (0)
  5. tests/test_dependency_yield_scope.py

    
    class Session:
        def __init__(self) -> None:
            self.open = True
    
    
    def dep_session() -> Any:
        s = Session()
        yield s
        s.open = False
    
    
    def raise_after_yield() -> Any:
        yield
        raise HTTPException(status_code=503, detail="Exception after yield")
    
    
    SessionFuncDep = Annotated[Session, Depends(dep_session, scope="function")]
    Registered: Sun Dec 28 07:19:09 UTC 2025
    - Last Modified: Wed Dec 17 21:25:59 UTC 2025
    - 6.7K bytes
    - Viewed (0)
  6. 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 }
    
    Registered: Sun Dec 28 07:19:09 UTC 2025
    - Last Modified: Wed Dec 17 20:41:43 UTC 2025
    - 7.9K bytes
    - Viewed (0)
  7. 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.
    
    Registered: Sun Dec 28 07:19:09 UTC 2025
    - Last Modified: Wed Dec 17 20:41:43 UTC 2025
    - 8.8K bytes
    - Viewed (0)
  8. tests/test_dependency_after_yield_websockets.py

                if self.open:
                    yield item
                else:
                    raise ValueError("Session closed")
    
    
    @contextmanager
    def acquire_session() -> Generator[Session, None, None]:
        session = Session()
        try:
            yield session
        finally:
            session.open = False
    
    
    def dep_session() -> Any:
        with acquire_session() as s:
            yield s
    
    
    def broken_dep_session() -> Any:
    Registered: Sun Dec 28 07:19:09 UTC 2025
    - Last Modified: Wed Dec 17 21:25:59 UTC 2025
    - 2K bytes
    - Viewed (0)
  9. 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:
    Registered: Sun Dec 28 07:19:09 UTC 2025
    - Last Modified: Wed Dec 17 21:25:59 UTC 2025
    - 1.7K bytes
    - Viewed (0)
  10. tests/test_dependency_partial.py

    def gen_dependency(value: str) -> Generator[str, None, None]:
        yield value
    
    
    async def async_gen_dependency(value: str) -> AsyncGenerator[str, None]:
        yield value
    
    
    class CallableDependency:
        def __call__(self, value: str) -> str:
            return value
    
    
    class CallableGenDependency:
        def __call__(self, value: str) -> Generator[str, None, None]:
            yield value
    
    
    class AsyncCallableDependency:
    Registered: Sun Dec 28 07:19:09 UTC 2025
    - Last Modified: Wed Dec 17 21:25:59 UTC 2025
    - 6.3K bytes
    - Viewed (0)
Back to top