From c480c24606fc1da03aa670aa460c545c3eddd0f1 Mon Sep 17 00:00:00 2001 From: Taha Yassine Kraiem Date: Tue, 11 Apr 2023 16:29:15 +0100 Subject: [PATCH] feat(chalice): use background-tasks list instead of single background task --- ee/api/chalicelib/core/traces.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/ee/api/chalicelib/core/traces.py b/ee/api/chalicelib/core/traces.py index d20134435..896f071bf 100644 --- a/ee/api/chalicelib/core/traces.py +++ b/ee/api/chalicelib/core/traces.py @@ -4,7 +4,7 @@ import re from typing import Optional, List from decouple import config -from fastapi import Request, Response +from fastapi import Request, Response, BackgroundTasks from pydantic import BaseModel, Field from starlette.background import BackgroundTask @@ -142,9 +142,9 @@ def trace(action: str, path_format: str, request: Request, response: Response): background_task: BackgroundTask = BackgroundTask(process_trace, action=action, path_format=path_format, request=request, response=response) if response.background is None: - response.background = background_task - else: - response.background.add_task(background_task) + response.background = BackgroundTasks() + + response.background.add_task(background_task) async def process_traces_queue():