a collection of background tasks that will be called after a response has been sent to the client read more about it in the fastapi docs for background taskshttps fastapi tiangolo comtutorialbackgroundtasks example python from fastapi import backgroundtasks fastapi app fastapi def writenotificationemail str message with openlog txt modew as emailfile content fnotification for email message emailfile writecontent app postsendnotificationemail async def sendnotificationemail str backgroundtasks backgroundtasks backgroundtasks addtaskwritenotification email messagesome notification return message notification sent in the background the function to call after the response is sent it can be a regular def function or an async def function add a function to be called in the background after the response is sent read more about it in the fastapi docs for background taskshttps fastapi tiangolo comtutorialbackgroundtasks type ignore attr defined a collection of background tasks that will be called after a response has been sent to the client read more about it in the fastapi docs for background tasks https fastapi tiangolo com tutorial background tasks example python from fastapi import backgroundtasks fastapi app fastapi def write_notification email str message with open log txt mode w as email_file content f notification for email message email_file write content 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 the function to call after the response is sent it can be a regular def function or an async def function add a function to be called in the background after the response is sent read more about it in the fastapi docs for background tasks https fastapi tiangolo com tutorial background tasks
from typing import Any, Callable

from starlette.background import BackgroundTasks as StarletteBackgroundTasks
from typing_extensions import Annotated, Doc, ParamSpec  

P = ParamSpec("P")


class BackgroundTasks(StarletteBackgroundTasks):
    

    def add_task(
        self,
        func: Annotated[
            Callable[P, Any],
            Doc(
                
            ),
        ],
        *args: P.args,
        **kwargs: P.kwargs,
    ) -> None:
        
        return super().add_task(func, *args, **kwargs)