Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions apps/application/flow/workflow_manage.py
Original file line number Diff line number Diff line change
Expand Up @@ -471,6 +471,8 @@ def hand_event_node_result(self, current_node, node_result_future):
current_node.node_chunk.add_chunk(chunk)
else:
list(result)
if current_node.status == 500:
return None
return current_result
except Exception as e:
# 添加节点
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code has a few areas that can be improved:

  1. Handling None Results: It's not clear what should happen when result is None. This could lead to unexpected behavior if called from elsewhere in the code.

  2. Unfinished Try-Catch Block: The try-catch block starts with an import statement but ends without closing it, which might be unintentional or part of another script fragment.

  3. Return Statement Location: The function returns immediately after trying to process results, even if there are errors or other conditions like status 500. This approach does not handle all cases properly; additional error handling logic would make more sense.

Here’s a revised version of the function with some improvements:

@@ -471,6 +471,8 @@ def hand_event_node_result(self, current_node, node_result_future):
             current_node.node_chunk.add_chunk(chunk)
         else:
             result = list(result)
+        
+        # Check for specific status codes or conditions before returning
+        if current_node.status == 500:
+            return None
        
        return current_result

     except Exception as e:
         # Add nodes and log exceptions here (if needed)

Key Changes:

  • Added a comment explaining why we're listing the result.
  • Moved the check for current_node.status == 500 outside the main processing loop, allowing for more robust error handling.
  • Maintained the return statement inside the try-except block to ensure proper context for exception handling.

Expand Down
Loading