Search Options

Results per page
Sort
Preferred Languages
Advance

Results 1 - 10 of 254 for __exit__ (0.04 sec)

  1. fastapi/concurrency.py

    async def contextmanager_in_threadpool(
        cm: AbstractContextManager[_T],
    ) -> AsyncGenerator[_T, None]:
        # blocking __exit__ from running waiting on a free thread
        # can create race conditions/deadlocks if the context manager itself
        # has its own internal pool (e.g. a database connection pool)
        # to avoid this we let __exit__ run without a capacity limit
        # since we're creating a new limiter for each call, any non-zero limit
    Registered: Sun Dec 28 07:19:09 UTC 2025
    - Last Modified: Wed Dec 17 21:25:59 UTC 2025
    - 1.5K bytes
    - Viewed (0)
  2. docs_src/dependencies/tutorial010_py39.py

    class MySuperContextManager:
        def __init__(self):
            self.db = DBSession()
    
        def __enter__(self):
            return self.db
    
        def __exit__(self, exc_type, exc_value, traceback):
            self.db.close()
    
    
    async def get_db():
        with MySuperContextManager() as db:
    Registered: Sun Dec 28 07:19:09 UTC 2025
    - Last Modified: Wed Dec 17 20:41:43 UTC 2025
    - 292 bytes
    - Viewed (0)
  3. docs/es/docs/tutorial/dependencies/dependencies-with-yield.md

    ///
    
    En Python, puedes crear Context Managers <a href="https://docs.python.org/3/reference/datamodel.html#context-managers" class="external-link" target="_blank">creando una clase con dos métodos: `__enter__()` y `__exit__()`</a>.
    
    También puedes usarlos dentro de las dependencias de **FastAPI** con `yield` usando
    `with` o `async with` en la función de dependencia:
    
    {* ../../docs_src/dependencies/tutorial010_py39.py hl[1:9,13] *}
    
    Registered: Sun Dec 28 07:19:09 UTC 2025
    - Last Modified: Wed Dec 17 20:41:43 UTC 2025
    - 13.7K bytes
    - Viewed (0)
  4. docs/zh/docs/tutorial/dependencies/dependencies-with-yield.md

    这是一个更为"高级"的想法。
    
    如果你刚开始使用 **FastAPI** ,你可以暂时可以跳过它。
    
    ///
    
    在Python中,你可以通过<a href="https://docs.python.org/3/reference/datamodel.html#context-managers" class="external-link" target="_blank">创建一个带有`__enter__()`和`__exit__()`方法的类</a>来创建上下文管理器。
    
    你也可以在 **FastAPI** 的 `yield` 依赖项中通过 `with` 或者 `async with` 语句来使用它们:
    
    {* ../../docs_src/dependencies/tutorial010.py hl[1:9,13] *}
    
    /// tip | 提示
    
    另一种创建上下文管理器的方法是:
    
    Registered: Sun Dec 28 07:19:09 UTC 2025
    - Last Modified: Mon Nov 18 02:25:44 UTC 2024
    - 11.3K bytes
    - Viewed (0)
  5. docs/ja/docs/tutorial/dependencies/dependencies-with-yield.md

    **FastAPI** を使い始めたばかりの方は、とりあえずスキップした方がよいかもしれません。
    
    ///
    
    Pythonでは、<a href="https://docs.python.org/3/reference/datamodel.html#context-managers" class="external-link" target="_blank">以下の2つのメソッドを持つクラスを作成する: `__enter__()`と`__exit__()`</a>ことでコンテキストマネージャを作成することができます。
    
    また、依存関数の中で`with`や`async with`文を使用することによって`yield`を持つ **FastAPI** の依存関係の中でそれらを使用することができます:
    
    {* ../../docs_src/dependencies/tutorial010.py hl[1,2,3,4,5,6,7,8,9,13] *}
    
    /// tip | 豆知識
    Registered: Sun Dec 28 07:19:09 UTC 2025
    - Last Modified: Mon Nov 18 02:25:44 UTC 2024
    - 12.3K bytes
    - Viewed (0)
  6. docs/ru/docs/tutorial/dependencies/dependencies-with-yield.md

    ///
    
    В Python можно создавать менеджеры контекста, <a href="https://docs.python.org/3/reference/datamodel.html#context-managers" class="external-link" target="_blank">создав класс с двумя методами: `__enter__()` и `__exit__()`</a>.
    
    Их также можно использовать внутри зависимостей **FastAPI** с `yield`, применяя операторы
    `with` или `async with` внутри функции зависимости:
    
    {* ../../docs_src/dependencies/tutorial010_py39.py hl[1:9,13] *}
    Registered: Sun Dec 28 07:19:09 UTC 2025
    - Last Modified: Wed Dec 17 20:41:43 UTC 2025
    - 19.7K bytes
    - Viewed (0)
  7. docs/de/docs/tutorial/dependencies/dependencies-with-yield.md

    ///
    
    In Python können Sie Kontextmanager erstellen, indem Sie <a href="https://docs.python.org/3/reference/datamodel.html#context-managers" class="external-link" target="_blank">eine Klasse mit zwei Methoden erzeugen: `__enter__()` und `__exit__()`</a>.
    
    Sie können solche auch innerhalb von **FastAPI**-Abhängigkeiten mit `yield` verwenden, indem Sie `with`- oder `async with`-Anweisungen innerhalb der Abhängigkeits-Funktion verwenden:
    
    Registered: Sun Dec 28 07:19:09 UTC 2025
    - Last Modified: Wed Dec 17 20:41:43 UTC 2025
    - 14.7K bytes
    - Viewed (0)
  8. docs/pt/docs/tutorial/dependencies/dependencies-with-yield.md

    ///
    
    Em Python, você pode criar Gerenciadores de Contexto ao <a href="https://docs.python.org/3/reference/datamodel.html#context-managers" class="external-link" target="_blank">criar uma classe com dois métodos: `__enter__()` e `__exit__()`</a>.
    
    Você também pode usá-los dentro de dependências com `yield` do **FastAPI** ao utilizar
    `with` ou `async with` dentro da função da dependência:
    
    {* ../../docs_src/dependencies/tutorial010_py39.py hl[1:9,13] *}
    Registered: Sun Dec 28 07:19:09 UTC 2025
    - Last Modified: Wed Dec 17 20:41:43 UTC 2025
    - 14.2K bytes
    - Viewed (0)
  9. docs/en/docs/tutorial/dependencies/dependencies-with-yield.md

    ///
    
    In Python, you can create Context Managers by <a href="https://docs.python.org/3/reference/datamodel.html#context-managers" class="external-link" target="_blank">creating a class with two methods: `__enter__()` and `__exit__()`</a>.
    
    You can also use them inside of **FastAPI** dependencies with `yield` by using
    `with` or `async with` statements inside of the dependency function:
    
    Registered: Sun Dec 28 07:19:09 UTC 2025
    - Last Modified: Wed Dec 17 20:41:43 UTC 2025
    - 12.9K bytes
    - Viewed (0)
  10. docs/ko/docs/tutorial/dependencies/dependencies-with-yield.md

    ///
    
    Python에서는 다음을 통해 컨텍스트 관리자를 생성할 수 있습니다. <a href="https://docs.python.org/3/reference/datamodel.html#context-managers" class="external-link" target="_blank"> 두 가지 메서드가 있는 클래스를 생성합니다: `__enter__()` and `__exit__()`</a>.
    
    **FastAPI**의 `yield`가 있는 의존성 내에서
    `with` 또는 `async with`문을 사용하여 이들을 활용할 수 있습니다:
    
    {* ../../docs_src/dependencies/tutorial010.py hl[1:9,13] *}
    
    /// tip | 팁
    
    컨텍스트 관리자를 생성하는 또 다른 방법은 다음과 같습니다:
    Registered: Sun Dec 28 07:19:09 UTC 2025
    - Last Modified: Sun Feb 09 14:54:09 UTC 2025
    - 14.2K bytes
    - Viewed (0)
Back to top