Search Options

Results per page
Sort
Preferred Languages
Advance

Results 1 - 3 of 3 for contextmanager (0.09 sec)

  1. tests/test_dependency_after_yield_streaming.py

    from collections.abc import Generator
    from contextlib import contextmanager
    from typing import Annotated, Any
    
    import pytest
    from fastapi import Depends, FastAPI
    from fastapi.responses import StreamingResponse
    from fastapi.testclient import TestClient
    
    
    class Session:
        def __init__(self) -> None:
            self.data = ["foo", "bar", "baz"]
            self.open = True
    
        def __iter__(self) -> Generator[str, None, None]:
    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_dependency_after_yield_websockets.py

    from collections.abc import Generator
    from contextlib import contextmanager
    from typing import Annotated, Any
    
    import pytest
    from fastapi import Depends, FastAPI, WebSocket
    from fastapi.testclient import TestClient
    
    
    class Session:
        def __init__(self) -> None:
            self.data = ["foo", "bar", "baz"]
            self.open = True
    
        def __iter__(self) -> Generator[str, None, None]:
            for item in self.data:
    Registered: Sun Dec 28 07:19:09 UTC 2025
    - Last Modified: Wed Dec 17 21:25:59 UTC 2025
    - 2K bytes
    - Viewed (0)
  3. docs/de/docs/advanced/events.md

    ```Python
    with open("file.txt") as file:
        file.read()
    ```
    
    In neueren Versionen von Python gibt es auch einen **asynchronen Kontextmanager**. Sie würden ihn mit `async with` verwenden:
    
    ```Python
    async with lifespan(app):
        await do_stuff()
    ```
    
    Registered: Sun Dec 28 07:19:09 UTC 2025
    - Last Modified: Wed Dec 17 20:41:43 UTC 2025
    - 9.5K bytes
    - Viewed (0)
Back to top