| Pattern | Count | % | Description |
|---|---|---|---|
1. Celery task .delay() |
13 | 76% | Async from routes/handlers |
| 2. Direct from route | 1 | 6% | Sync, blocks request |
| 3. Direct from Celery task | 3 | 18% | Already async context |
Total: 17 email send points
Async via email_async.on_x.delay() - Recommended for routes/handlers
| File | Line | Task |
|---|---|---|
handlers/inventory_model_users_handlers.py |
116 | on_model_user_added |
handlers/inventory_model_users_handlers.py |
190 | on_model_user_deleted |
handlers/inventory_model_findings_handlers.py |
189 | on_model_finding_created |
handlers/inventory_model_handlers.py |
157 | on_workflow_transition_status_set |
handlers/inventory_model_handlers.py |
718 | on_inventory_model_created |
routes/tracking.py |
535 | on_inventory_model_monitoring_breach |
routes/ui_users.py |
531 | on_user_invited |
routes/ui_users.py |
687 | on_organization_user_added |
routes/ui_model_document_metadatas.py |
584 | on_model_comment_added |
routes/ui_model_document_metadatas.py |
750 | on_model_comment_added |
routes/ui_workflows.py |
527 | on_workflow_transition_user_action |
routes/ui_workflows.py |
753 | on_workflow_transition_user_action |
workflows/managers.py |
3446 | on_broadcast_notification |
Sync call via EmailNotification.send_email() - Blocks HTTP response
| File | Line | Call |
|---|---|---|
routes/public_onboarding/amazon_marketplace.py |
251 | EmailNotification.send_email() |
Use case: One-off cases where blocking is acceptable (e.g., onboarding completion)
Direct call via EmailNotification.on_x() - Already in async context
| File | Line | Call |
|---|---|---|
tasks/attestations.py |
93 | EmailNotification.on_attestation_blocked() |
tasks/attestations.py |
276 | EmailNotification.on_attestation_reminder() |
tasks/attestations.py |
597 | EmailNotification.on_attestation_reminder() |
Use case: Scheduled/batch jobs that are already running as Celery tasks
| Scenario | Use Pattern |
|---|---|
| From HTTP route, need non-blocking | Pattern 1 - email_async.on_x.delay() |
| From HTTP route, OK to block | Pattern 2 - EmailNotification.send_email() |
| From existing Celery task | Pattern 3 - EmailNotification.on_x() directly |
Pattern 1 is the preferred default for routes since it doesn't slow down API responses.