From afaf3d6e26df27093e2aec038cef51040f8bebc7 Mon Sep 17 00:00:00 2001 From: shaohuzhang1 <80892890+shaohuzhang1@users.noreply.github.com> Date: Thu, 27 Feb 2025 14:21:47 +0800 Subject: [PATCH] fix: The workflow cannot function properly after the conversation flow is disconnected (#2428) --- apps/application/flow/workflow_manage.py | 2 ++ apps/common/middleware/gzip.py | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/apps/application/flow/workflow_manage.py b/apps/application/flow/workflow_manage.py index a0d491a84..d6bb43bf6 100644 --- a/apps/application/flow/workflow_manage.py +++ b/apps/application/flow/workflow_manage.py @@ -382,6 +382,8 @@ class WorkflowManage: break yield chunk finally: + while self.is_run(): + pass details = self.get_runtime_details() message_tokens = sum([row.get('message_tokens') for row in details.values() if 'message_tokens' in row and row.get('message_tokens') is not None]) diff --git a/apps/common/middleware/gzip.py b/apps/common/middleware/gzip.py index 229ec09b3..92c7cea38 100644 --- a/apps/common/middleware/gzip.py +++ b/apps/common/middleware/gzip.py @@ -44,10 +44,10 @@ class GZipMiddleware(MiddlewareMixin): if response.is_async: # pull to lexical scope to capture fixed reference in case # streaming_content is set again later. - orignal_iterator = response.streaming_content + original_iterator = response.streaming_content async def gzip_wrapper(): - async for chunk in orignal_iterator: + async for chunk in original_iterator: yield compress_string( chunk, max_random_bytes=self.max_random_bytes,