Search Options

Results per page
Sort
Preferred Languages
Advance

Results 1 - 10 of 26 for shutdown (0.37 sec)

  1. docs/en/docs/advanced/testing-events.md

    # Testing Events: startup - shutdown
    
    When you need your event handlers (`startup` and `shutdown`) to run in your tests, you can use the `TestClient` with a `with` statement:
    
    ```Python hl_lines="9-12  20-24"
    {!../../../docs_src/app_testing/tutorial003.py!}
    Plain Text
    - Registered: Sun May 05 07:19:11 GMT 2024
    - Last Modified: Sat Aug 29 14:02:58 GMT 2020
    - 262 bytes
    - Viewed (0)
  2. docs/zh/docs/advanced/testing-events.md

    # 测试事件:启动 - 关闭
    
    使用 `TestClient` 和 `with` 语句,在测试中运行事件处理器(`startup` 与 `shutdown`)。
    
    ```Python hl_lines="9-12  20-24"
    {!../../../docs_src/app_testing/tutorial003.py!}
    Plain Text
    - Registered: Sun May 05 07:19:11 GMT 2024
    - Last Modified: Sun Jan 28 18:21:02 GMT 2024
    - 228 bytes
    - Viewed (0)
  3. docs_src/events/tutorial002.py

    from fastapi import FastAPI
    
    app = FastAPI()
    
    
    @app.on_event("shutdown")
    def shutdown_event():
        with open("log.txt", mode="a") as log:
            log.write("Application shutdown")
    
    
    @app.get("/items/")
    async def read_items():
    Python
    - Registered: Sun May 05 07:19:11 GMT 2024
    - Last Modified: Thu Mar 26 19:09:53 GMT 2020
    - 255 bytes
    - Viewed (0)
  4. docs/de/docs/advanced/events.md

    ### `shutdown`-Event
    
    Um eine Funktion hinzuzufügen, die beim Herunterfahren der Anwendung ausgeführt werden soll, deklarieren Sie sie mit dem Event `shutdown`:
    
    ```Python hl_lines="6"
    {!../../../docs_src/events/tutorial002.py!}
    ```
    
    Hier schreibt die `shutdown`-Eventhandler-Funktion eine Textzeile `"Application shutdown"` in eine Datei `log.txt`.
    
    !!! info
    Plain Text
    - Registered: Sun May 05 07:19:11 GMT 2024
    - Last Modified: Sat Mar 30 20:30:59 GMT 2024
    - 9.1K bytes
    - Viewed (0)
  5. docs/pt/docs/advanced/events.md

    ### Evento `shutdown`
    
    Para adicionar uma função que deve ser executada quando a aplicação estiver encerrando, declare ela com o evento `"shutdown"`:
    
    ```Python hl_lines="6"
    {!../../../docs_src/events/tutorial002.py!}
    ```
    
    Aqui, a função de manipulação de evento `shutdown` irá escrever uma linha de texto `"Application shutdown"` no arquivo `log.txt`.
    
    !!! info "Informação"
    Plain Text
    - Registered: Sun May 05 07:19:11 GMT 2024
    - Last Modified: Thu Apr 18 19:53:19 GMT 2024
    - 8.6K bytes
    - Viewed (0)
  6. tests/test_tutorial/test_events/test_tutorial002.py

            response = client.get("/items/")
            assert response.status_code == 200, response.text
            assert response.json() == [{"name": "Foo"}]
        with open("log.txt") as log:
            assert "Application shutdown" in log.read()
    
    
    def test_openapi_schema(app: FastAPI):
        with TestClient(app) as client:
            response = client.get("/openapi.json")
            assert response.status_code == 200, response.text
    Python
    - Registered: Sun Apr 28 07:19:10 GMT 2024
    - Last Modified: Wed Oct 18 12:36:40 GMT 2023
    - 1.4K bytes
    - Viewed (0)
  7. tests/test_router_events.py

            state.app_startup = True
    
        @app.on_event("shutdown")
        def app_shutdown() -> None:
            state.app_shutdown = True
    
        router = APIRouter()
    
        @router.on_event("startup")
        def router_startup() -> None:
            state.router_startup = True
    
        @router.on_event("shutdown")
        def router_shutdown() -> None:
            state.router_shutdown = True
    
        sub_router = APIRouter()
    
    Python
    - Registered: Sun May 05 07:19:11 GMT 2024
    - Last Modified: Wed Oct 18 12:36:40 GMT 2023
    - 3.2K bytes
    - Viewed (0)
  8. docs/vi/docs/features.md

    * Hỗ trợ **WebSocket**.
    * In-process background tasks.
    * Startup and shutdown events.
    * Client cho kiểm thử xây dựng trên HTTPX.
    * **CORS**, GZip, Static Files, Streaming responses.
    * Hỗ trợ **Session and Cookie**.
    * 100% test coverage.
    * 100% type annotated codebase.
    
    Plain Text
    - Registered: Sun May 05 07:19:11 GMT 2024
    - Last Modified: Thu Apr 18 19:53:19 GMT 2024
    - 11.6K bytes
    - Viewed (0)
  9. docs/de/docs/advanced/testing-events.md

    # Events testen: Hochfahren – Herunterfahren
    
    Wenn Sie in Ihren Tests Ihre Event-Handler (`startup` und `shutdown`) ausführen wollen, können Sie den `TestClient` mit einer `with`-Anweisung verwenden:
    
    ```Python hl_lines="9-12  20-24"
    {!../../../docs_src/app_testing/tutorial003.py!}
    Plain Text
    - Registered: Sun May 05 07:19:11 GMT 2024
    - Last Modified: Sat Mar 30 20:17:40 GMT 2024
    - 291 bytes
    - Viewed (0)
  10. docs/em/docs/advanced/testing-events.md

    # 🔬 🎉: 🕴 - 🤫
    
    🕐❔ 👆 💪 👆 🎉 🐕‍🦺 (`startup` & `shutdown`) 🏃 👆 💯, 👆 💪 ⚙️ `TestClient` ⏮️ `with` 📄:
    
    ```Python hl_lines="9-12  20-24"
    {!../../../docs_src/app_testing/tutorial003.py!}
    Plain Text
    - Registered: Sun May 05 07:19:11 GMT 2024
    - Last Modified: Sat Apr 01 09:26:04 GMT 2023
    - 248 bytes
    - Viewed (0)
Back to top