Skip to content

Commit

Permalink
TN-3226 new celery job to intentionally raise exceptions (#4305)
Browse files Browse the repository at this point in the history
NB, this job is not scheduled, but can be manually triggered anytime we
need to verify handling and routing of errors.
  • Loading branch information
pbugni authored Apr 10, 2023
1 parent 9f46457 commit 64dca19
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
11 changes: 11 additions & 0 deletions portal/config/eproms/ScheduledJob.json
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,17 @@
"resourceType": "ScheduledJob",
"schedule": "1 4,10,16,22 * * *",
"task": "process_triggers_task"
},
{
"active": false,
"args": null,
"kwargs": {
"exception_type": "ValueError"
},
"name": "Raise Background Exception",
"resourceType": "ScheduledJob",
"schedule": "0 0 0 0 0",
"task": "raise_background_exception_task"
}
],
"id": "SitePersistence v0.2",
Expand Down
11 changes: 11 additions & 0 deletions portal/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -413,3 +413,14 @@ def process_triggers_task(**kwargs):
# Include within function as not all applications include the blueprint
from portal.trigger_states.empro_states import fire_trigger_events
fire_trigger_events()


@celery.task()
@scheduled_task
def raise_background_exception_task(**kwargs):
"""Manually trigger to verify job raised exceptions are caught"""
if kwargs.get("exception_type") == "RuntimeError":
raise RuntimeError("intentional RuntimeError raised from task")
if kwargs.get("exception_type") == "ValueError":
raise ValueError("intentional ValueError raised from task")
raise Exception("intentional Exception raised from task")

0 comments on commit 64dca19

Please sign in to comment.