mirror of
https://github.com/inventree/InvenTree.git
synced 2025-04-29 20:16:44 +00:00
- Trigger a new background task for each plugin - Call plugin.process_event - Plugin class can then decide what to do with the particular event
38 lines
837 B
Python
38 lines
837 B
Python
"""
|
|
Sample plugin which supports task scheduling
|
|
"""
|
|
|
|
from plugin import IntegrationPluginBase
|
|
from plugin.mixins import ScheduleMixin
|
|
|
|
|
|
# Define some simple tasks to perform
|
|
def print_hello():
|
|
print("Hello")
|
|
|
|
|
|
def print_world():
|
|
print("World")
|
|
|
|
|
|
class ScheduledTaskPlugin(ScheduleMixin, IntegrationPluginBase):
|
|
"""
|
|
A sample plugin which provides support for scheduled tasks
|
|
"""
|
|
|
|
PLUGIN_NAME = "ScheduledTasksPlugin"
|
|
PLUGIN_SLUG = "schedule"
|
|
PLUGIN_TITLE = "Scheduled Tasks"
|
|
|
|
SCHEDULED_TASKS = {
|
|
'hello': {
|
|
'func': 'plugin.samples.integration.scheduled_task.print_hello',
|
|
'schedule': 'I',
|
|
'minutes': 45,
|
|
},
|
|
'world': {
|
|
'func': 'plugin.samples.integration.scheduled_task.print_hello',
|
|
'schedule': 'H',
|
|
},
|
|
}
|