Performance: Calling tasks asynchronously
HIGH IMPACT
This affects how quickly the main web request responds by offloading long-running tasks to background workers.
from myapp.tasks import long_running_task def view(request): long_running_task.delay() return HttpResponse("Task started, response sent immediately")
def view(request): result = long_running_task() return HttpResponse(f"Result: {result}")
| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Synchronous task in view | Minimal | N/A | Blocks paint until response | [X] Bad |
| Asynchronous task with Celery | Minimal | N/A | Immediate paint and interaction | [OK] Good |