Files
cms-website/.deps_siteforge_v812/fastapi/__pycache__/background.cpython-312.pyc
T

44 lines
2.3 KiB
Plaintext
Raw Normal View History

Ë
ñÅÙjãób—ddlmZmZmZddlmZddlmZddl m
Z
e
d«Z Gd„de«Zy) é)Ú AnnotatedÚAnyÚCallable)ÚDoc)ÚBackgroundTasks)Ú ParamSpecÚPcó|‡—eZdZdZdeeeefed«fdejdejddfˆfd„ Z ˆxZ S) raG
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ó*•—t‰|�|g|¢­i|¤ŽS)zä
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/).
)ÚsuperÚadd_task)Úselfr r r
Ú __class__s €úVC:\Users\30997\AppData\Local\Temp\pip-target-6g32zz5s\lib\python\fastapi/background.pyrzBackgroundTasks.add_task'sø€ô*‰wÑ Ð6 tÒ6¨vÑ6Ð6ó)
Ú__name__Ú
__module__Ú __qualname__Ú__doc__rrr rrr r
rÚ