INNER CODE UNIT · Python
failing_task
doganarif/fastapi-radar · example_app.py:321
async def failing_task():
"""Example task that fails."""
import asyncio
await asyncio.sleep(0.5)
raise Exception("Simulated task failure for testing")
@app.post("/send-email")
async def send_email(email: str, subject: str, background_tasks: BackgroundTasks):
"""Example endpoint that triggers a background task."""
background_tasks.add_task(send_email_task, email, subject)
return {"message": "Email will be sent in the background"}
@app.post("/process-report/{user_id}")
async def process_user_report(user_id: int, background_tasks: BackgroundTasks):
"""Example endpoint that triggers a long-running background task."""