Skip to content

Commit 36dd54b

Browse files
committed
[SPARK-1466] Raise exception if Gateway process doesn't start.
Also include stderr output to help user debug startup issue.
1 parent 6113ac1 commit 36dd54b

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

python/pyspark/java_gateway.py

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,19 @@ def launch_gateway():
4343
# Don't send ctrl-c / SIGINT to the Java gateway:
4444
def preexec_func():
4545
signal.signal(signal.SIGINT, signal.SIG_IGN)
46-
proc = Popen(command, stdout=PIPE, stdin=PIPE, preexec_fn=preexec_func)
46+
proc = Popen(command, stdout=PIPE, stdin=PIPE, stderr=PIPE, preexec_fn=preexec_func)
4747
else:
4848
# preexec_fn not supported on Windows
49-
proc = Popen(command, stdout=PIPE, stdin=PIPE)
50-
# Determine which ephemeral port the server started on:
51-
gateway_port = int(proc.stdout.readline())
49+
proc = Popen(command, stdout=PIPE, stdin=PIPE, stderr=PIPE)
50+
51+
try:
52+
# Determine which ephemeral port the server started on:
53+
gateway_port = int(proc.stdout.readline())
54+
except:
55+
error_code = proc.poll()
56+
raise Exception("Launching GatewayServer failed with exit code %d: %s" %
57+
(error_code, "".join(proc.stderr.readlines())))
58+
5259
# Create a thread to echo output from the GatewayServer, which is required
5360
# for Java log output to show up:
5461
class EchoOutputThread(Thread):

0 commit comments

Comments
 (0)