feat(chalice): use background-tasks list instead of single background task

This commit is contained in:
Taha Yassine Kraiem 2023-04-11 16:29:15 +01:00
parent 7bce53bc1e
commit c480c24606

View file

@ -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():