Skip to content

Commit 67a8f42

Browse files
committed
handle command return code in launch_gateway function
1 parent 87a3b06 commit 67a8f42

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

python/pyspark/java_gateway.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,9 +104,16 @@ def preexec_func():
104104
proc = Popen(command, **popen_kwargs)
105105

106106
# Wait for the file to appear, or for the process to exit, whichever happens first.
107-
while not proc.poll() and not os.path.isfile(conn_info_file):
107+
while proc.poll() is None and not os.path.isfile(conn_info_file):
108108
time.sleep(0.1)
109109

110+
return_code = proc.poll()
111+
if return_code is not None and return_code != 0:
112+
raise PySparkRuntimeError(
113+
errorClass="JAVA_GATEWAY_EXITED",
114+
messageParameters={"command": " ".join(command), "return_code": return_code},
115+
)
116+
110117
if not os.path.isfile(conn_info_file):
111118
raise PySparkRuntimeError(
112119
errorClass="JAVA_GATEWAY_EXITED",

0 commit comments

Comments
 (0)