fix: Error in total time consumption statistics for executing records (#4459)

This commit is contained in:
shaohuzhang1 2025-12-08 15:48:48 +08:00 committed by GitHub
parent 1869b47dde
commit ff26835c93
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 6 additions and 1 deletions

View File

@ -105,8 +105,11 @@ class KnowledgeWorkflowPostHandler(WorkFlowPostHandler):
self.knowledge_action_id = knowledge_action_id
def handler(self, workflow):
err = [True for key, value in workflow.get_runtime_details().items() if value.get('status') == 500]
QuerySet(KnowledgeAction).filter(id=self.knowledge_action_id).update(
state=State.SUCCESS)
state=State.FAILURE if any(err) else State.SUCCESS,
run_time=time.time() - workflow.context.get('start_time') if workflow.context.get(
'start_time') is not None else 0)
class NodeResult:

View File

@ -6,6 +6,7 @@
@date2025/11/13 19:02
@desc:
"""
import time
import traceback
from concurrent.futures import ThreadPoolExecutor
@ -43,6 +44,7 @@ class KnowledgeWorkflowManage(WorkflowManage):
return start_node_list[0]
def run(self):
self.context['start_time'] = time.time()
executor.submit(self._run)
def _run(self):