�
K�g� � �h � d dl mZmZ d dlmZ d dlmZmZm Z e d� � Z
G d� de� � ZdS )� )�Any�Callable)�BackgroundTasks)� Annotated�Doc� ParamSpec�Pc �z � � e Zd ZdZdeeeef ed� � f dej dej
ddf� fd�Z� xZS ) r aG
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"}
```
�funcz�
The function to call after the response is sent.
It can be a regular `def` function or an `async def` function.
�args�kwargs�returnNc �>