Search Options

Display Count
Sort
Preferred Language
Advanced Search

Results 1 - 10 of 21 for add_task (0.32 seconds)

  1. fastapi/background.py

        @app.post("/send-notification/{email}")
        async def send_notification(email: str, background_tasks: BackgroundTasks):
            background_tasks.add_task(write_notification, email, message="some notification")
            return {"message": "Notification sent in the background"}
        ```
        """
    
        def add_task(
            self,
            func: Annotated[
                Callable[P, Any],
                Doc(
                    """
    Created: Sun Apr 05 07:19:11 GMT 2026
    - Last Modified: Wed Feb 11 18:41:21 GMT 2026
    - 1.8K bytes
    - Click Count (0)
  2. docs/en/docs/tutorial/background-tasks.md

    ## Add the background task { #add-the-background-task }
    
    Inside of your *path operation function*, pass your task function to the *background tasks* object with the method `.add_task()`:
    
    {* ../../docs_src/background_tasks/tutorial001_py310.py hl[14] *}
    
    `.add_task()` receives as arguments:
    
    * A task function to be run in the background (`write_notification`).
    Created: Sun Apr 05 07:19:11 GMT 2026
    - Last Modified: Thu Mar 05 18:13:19 GMT 2026
    - 4.7K bytes
    - Click Count (0)
  3. docs/zh-hant/docs/tutorial/background-tasks.md

    由於寫入操作未使用 `async` 與 `await`,因此以一般的 `def` 定義該函式:
    
    {* ../../docs_src/background_tasks/tutorial001_py310.py hl[6:9] *}
    
    ## 新增背景任務 { #add-the-background-task }
    
    在路徑操作函式內,使用 `.add_task()` 將任務函式加入背景任務物件:
    
    {* ../../docs_src/background_tasks/tutorial001_py310.py hl[14] *}
    
    `.add_task()` 的引數包括:
    
    * 要在背景執行的任務函式(`write_notification`)。
    * 依序傳給任務函式的位置引數(`email`)。
    * 要傳給任務函式的關鍵字引數(`message="some notification"`)。
    
    ## 相依性注入 { #dependency-injection }
    
    Created: Sun Apr 05 07:19:11 GMT 2026
    - Last Modified: Fri Mar 20 17:05:38 GMT 2026
    - 4.1K bytes
    - Click Count (0)
  4. docs/zh/docs/tutorial/background-tasks.md

    {* ../../docs_src/background_tasks/tutorial001_py310.py hl[6:9] *}
    
    ## 添加后台任务 { #add-the-background-task }
    
    在你的 *路径操作函数* 里,用 `.add_task()` 方法将任务函数传到 *后台任务* 对象中:
    
    {* ../../docs_src/background_tasks/tutorial001_py310.py hl[14] *}
    
    `.add_task()` 接收以下参数:
    
    * 在后台运行的任务函数(`write_notification`)。
    * 应按顺序传递给任务函数的任意参数序列(`email`)。
    * 应传递给任务函数的任意关键字参数(`message="some notification"`)。
    
    Created: Sun Apr 05 07:19:11 GMT 2026
    - Last Modified: Fri Mar 20 17:06:37 GMT 2026
    - 4.1K bytes
    - Click Count (0)
  5. docs/ja/docs/tutorial/background-tasks.md

    {* ../../docs_src/background_tasks/tutorial001_py310.py hl[6:9] *}
    
    ## バックグラウンドタスクの追加 { #add-the-background-task }
    
    *path operation function* 内で、`.add_task()` メソッドを使用してタスク関数を *background tasks* オブジェクトに渡します。
    
    {* ../../docs_src/background_tasks/tutorial001_py310.py hl[14] *}
    
    `.add_task()` は以下の引数を受け取ります:
    
    * バックグラウンドで実行されるタスク関数 (`write_notification`)。
    * タスク関数に順番に渡す必要のある引数の列 (`email`)。
    * タスク関数に渡す必要のあるキーワード引数 (`message="some notification"`)。
    Created: Sun Apr 05 07:19:11 GMT 2026
    - Last Modified: Fri Mar 20 14:07:17 GMT 2026
    - 5.8K bytes
    - Click Count (0)
  6. docs_src/background_tasks/tutorial002_py310.py

        if q:
            message = f"found query: {q}\n"
            background_tasks.add_task(write_log, message)
        return q
    
    
    @app.post("/send-notification/{email}")
    async def send_notification(
        email: str, background_tasks: BackgroundTasks, q: str = Depends(get_query)
    ):
        message = f"message to {email}\n"
        background_tasks.add_task(write_log, message)
    Created: Sun Apr 05 07:19:11 GMT 2026
    - Last Modified: Fri Jan 07 14:11:31 GMT 2022
    - 643 bytes
    - Click Count (0)
  7. docs_src/background_tasks/tutorial002_an_py310.py

        if q:
            message = f"found query: {q}\n"
            background_tasks.add_task(write_log, message)
        return q
    
    
    @app.post("/send-notification/{email}")
    async def send_notification(
        email: str, background_tasks: BackgroundTasks, q: Annotated[str, Depends(get_query)]
    ):
        message = f"message to {email}\n"
        background_tasks.add_task(write_log, message)
    Created: Sun Apr 05 07:19:11 GMT 2026
    - Last Modified: Sat Mar 18 12:29:59 GMT 2023
    - 683 bytes
    - Click Count (0)
  8. docs/tr/docs/tutorial/background-tasks.md

    ## Arka Plan Görevini Ekleyin { #add-the-background-task }
    
    *Path operation function*’ınızın içinde, görev fonksiyonunuzu `.add_task()` metodu ile *background tasks* objesine ekleyin:
    
    {* ../../docs_src/background_tasks/tutorial001_py310.py hl[14] *}
    
    `.add_task()` şu argümanları alır:
    
    * Arka planda çalıştırılacak bir görev fonksiyonu (`write_notification`).
    Created: Sun Apr 05 07:19:11 GMT 2026
    - Last Modified: Fri Mar 20 07:53:17 GMT 2026
    - 5K bytes
    - Click Count (0)
  9. tests/test_response_dependency.py

        def add_background_task(background_tasks: BackgroundTasks) -> BackgroundTasks:
            background_tasks.add_task(background_task, "from dependency")
            return background_tasks
    
        @app.get("/")
        def endpoint(
            background_tasks: Annotated[BackgroundTasks, Depends(add_background_task)],
        ):
            background_tasks.add_task(background_task, "from endpoint")
            return {"status": "ok"}
    
        client = TestClient(app)
    Created: Sun Apr 05 07:19:11 GMT 2026
    - Last Modified: Thu Feb 05 18:23:16 GMT 2026
    - 5.2K bytes
    - Click Count (0)
  10. docs/pt/docs/tutorial/background-tasks.md

    Dentro da sua *função de operação de rota*, passe sua função de tarefa para o objeto de *tarefas em segundo plano* com o método `.add_task()`:
    
    {* ../../docs_src/background_tasks/tutorial001_py310.py hl[14] *}
    
    O `.add_task()` recebe como argumentos:
    
    * Uma função de tarefa a ser executada em segundo plano (`write_notification`).
    Created: Sun Apr 05 07:19:11 GMT 2026
    - Last Modified: Thu Mar 19 18:20:43 GMT 2026
    - 5.1K bytes
    - Click Count (0)
Back to Top