turboFei commented on code in PR #6612:
URL: https://github.com/apache/kyuubi/pull/6612#discussion_r1720092496


##########
externals/kyuubi-spark-sql-engine/src/main/resources/python/execute_python.py:
##########
@@ -471,53 +471,68 @@ def main():
     try:
 
         while True:
-            line = sys_stdin.readline()
-
-            if line == "":
-                break
-            elif line == "\n":
-                continue
-
-            try:
-                content = json.loads(line)
-            except ValueError:
-                continue
-
-            if content["cmd"] == "exit_worker":
-                break
-
-            result = execute_request(content)
-
             try:
-                result = json.dumps(result)
-            except ValueError:
+                line = sys_stdin.readline()
+
+                if line == "":
+                    break
+                elif line == "\n":
+                    continue
+
+                try:
+                    content = json.loads(line)
+                except ValueError:
+                    continue
+
+                if content["cmd"] == "exit_worker":
+                    break
+
+                result = execute_request(content)
+
+                try:
+                    result = json.dumps(result)
+                except ValueError:
+                    result = json.dumps(
+                        {
+                            "msg_type": "inspect_reply",
+                            "content": {
+                                "status": "error",
+                                "ename": "ValueError",
+                                "evalue": "cannot json-ify %s" % result,
+                                "traceback": [],
+                            },
+                        }
+                    )
+                except Exception:
+                    exc_type, exc_value, tb = sys.exc_info()
+                    result = json.dumps(
+                        {
+                            "msg_type": "inspect_reply",
+                            "content": {
+                                "status": "error",
+                                "ename": str(exc_type.__name__),
+                                "evalue": "cannot json-ify %s: %s"
+                                % (result, str(exc_value)),
+                                "traceback": [],
+                            },
+                        }
+                    )
+
+                print(result, file=sys_stdout)
+            except KeyboardInterrupt:
                 result = json.dumps(
                     {
                         "msg_type": "inspect_reply",
                         "content": {
-                            "status": "error",
-                            "ename": "ValueError",
-                            "evalue": "cannot json-ify %s" % result,
+                            "status": "cancel",
+                            "ename": "KeyboardInterrupt",
+                            "evalue": "user cancel",

Review Comment:
   Execution interrupted by user



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscr...@kyuubi.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscr...@kyuubi.apache.org
For additional commands, e-mail: notifications-h...@kyuubi.apache.org

Reply via email to