mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
Add a task which fails on purpose
This commit is contained in:
parent
36feef6558
commit
c04e07c1fa
@ -102,16 +102,16 @@ 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():
|
||||
|
||||
|
||||
if 'func' not in task:
|
||||
raise ValueError(f"Task '{key}' is missing 'func' parameter")
|
||||
|
||||
|
||||
if 'schedule' not in task:
|
||||
raise ValueError(f"Task '{key}' is missing 'schedule' parameter")
|
||||
|
||||
|
||||
schedule = task['schedule'].upper().strip()
|
||||
|
||||
if schedule not in self.ALLOWABLE_SCHEDULE_TYPES:
|
||||
@ -153,7 +153,6 @@ class ScheduleMixin:
|
||||
minutes=task.get('minutes', None),
|
||||
repeats=task.get('repeats', -1),
|
||||
)
|
||||
|
||||
|
||||
def unregister_tasks(self):
|
||||
"""
|
||||
|
@ -299,7 +299,7 @@ class PluginsRegistry:
|
||||
def activate_integration_schedule(self, plugins):
|
||||
|
||||
logger.info('Activating plugin tasks')
|
||||
|
||||
|
||||
from common.models import InvenTreeSetting
|
||||
from django_q.models import Schedule
|
||||
|
||||
@ -307,7 +307,7 @@ class PluginsRegistry:
|
||||
task_keys = []
|
||||
|
||||
if settings.PLUGIN_TESTING or InvenTreeSetting.get_setting('ENABLE_PLUGINS_SCHEDULE'):
|
||||
|
||||
|
||||
for slug, plugin in plugins:
|
||||
|
||||
if plugin.mixin_enabled('schedule'):
|
||||
@ -427,7 +427,7 @@ class PluginsRegistry:
|
||||
"""
|
||||
Deactivate integration app - some magic required
|
||||
"""
|
||||
|
||||
|
||||
# unregister models from admin
|
||||
for plugin_path in self.installed_apps:
|
||||
models = [] # the modelrefs need to be collected as poping an item in a iter is not welcomed
|
||||
|
@ -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',
|
||||
},
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user