From 9745a8e6681851e497d6e1b99b0c3cefef53406f Mon Sep 17 00:00:00 2001 From: peterxcli Date: Wed, 24 Dec 2025 16:06:42 +0800 Subject: [PATCH] handle command return code in launch_gateway function --- python/pyspark/java_gateway.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/python/pyspark/java_gateway.py b/python/pyspark/java_gateway.py index 6303a43618578..251b0ddc18a7f 100644 --- a/python/pyspark/java_gateway.py +++ b/python/pyspark/java_gateway.py @@ -104,9 +104,16 @@ def preexec_func(): proc = Popen(command, **popen_kwargs) # Wait for the file to appear, or for the process to exit, whichever happens first. - while not proc.poll() and not os.path.isfile(conn_info_file): + while proc.poll() is None and not os.path.isfile(conn_info_file): time.sleep(0.1) + return_code = proc.poll() + if return_code is not None and return_code != 0: + raise PySparkRuntimeError( + errorClass="JAVA_GATEWAY_EXITED", + messageParameters={"command": " ".join(command), "return_code": return_code}, + ) + if not os.path.isfile(conn_info_file): raise PySparkRuntimeError( errorClass="JAVA_GATEWAY_EXITED",