feat:工作流手动中止

This commit is contained in:
jxxghp
2025-02-28 19:02:38 +08:00
parent 4086ba4763
commit 1bd12a9411
18 changed files with 148 additions and 67 deletions
+4 -1
View File
@@ -1,6 +1,7 @@
import copy
from app.actions import BaseAction
from app.core.config import global_vars
from app.schemas import ActionParams, ActionContext
from app.core.event import eventmanager
@@ -36,7 +37,7 @@ class SendEventAction(BaseAction):
def success(self) -> bool:
return self.done
def execute(self, params: dict, context: ActionContext) -> ActionContext:
def execute(self, workflow_id: int, params: dict, context: ActionContext) -> ActionContext:
"""
发送events中的事件
"""
@@ -44,6 +45,8 @@ class SendEventAction(BaseAction):
# 按优先级排序,优先级高的先发送
context.events.sort(key=lambda x: x.priority, reverse=True)
for event in copy.deepcopy(context.events):
if global_vars.is_workflow_stopped(workflow_id):
break
eventmanager.send_event(etype=event.event_type, data=event.event_data)
context.events.remove(event)