Performance: Defining tasks
MEDIUM IMPACT
This affects how background work impacts server responsiveness and page load times.
from celery import shared_task @shared_task def long_task(): # Long running code here pass def view(request): long_task.delay() return HttpResponse('Task started')
def view(request): # Long task runs synchronously result = long_task() return HttpResponse(result)
| Pattern | Server Blocking | Response Delay | User Interaction Impact | Verdict |
|---|---|---|---|---|
| Synchronous task in view | Blocks server thread | Delays response by task duration | High input delay (INP) | [X] Bad |
| Asynchronous task with Celery | No blocking | Immediate response | Low input delay (INP) | [OK] Good |