feat(chalice): use background-tasks list instead of single background task
This commit is contained in:
parent
7bce53bc1e
commit
c480c24606
1 changed files with 4 additions and 4 deletions
|
|
@ -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():
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue