2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-04-29 20:16:44 +00:00

Add a task which fails on purpose

This commit is contained in:
Oliver Walters 2022-01-07 17:04:33 +11:00
parent 36feef6558
commit c04e07c1fa
3 changed files with 17 additions and 10 deletions

View File

@ -102,7 +102,7 @@ class ScheduleMixin:
"""
if not self.has_scheduled_tasks:
raise ValueError(f"SCHEDULED_TASKS not defined")
raise ValueError("SCHEDULED_TASKS not defined")
for key, task in self.scheduled_tasks.items():
@ -154,7 +154,6 @@ class ScheduleMixin:
repeats=task.get('repeats', -1),
)
def unregister_tasks(self):
"""
Deregister the tasks with the database

View File

@ -15,6 +15,10 @@ def print_world():
print("World")
def fail_task():
raise ValueError("This task should fail!")
class ScheduledTaskPlugin(ScheduleMixin, IntegrationPluginBase):
"""
A sample plugin which provides support for scheduled tasks
@ -33,5 +37,9 @@ class ScheduledTaskPlugin(ScheduleMixin, IntegrationPluginBase):
'world': {
'func': 'plugin.samples.integration.scheduled_task.print_hello',
'schedule': 'H',
}
},
'failure': {
'func': 'plugin.samples.integration.scheduled_task.fail_task',
'schedule': 'D',
},
}