From e96a7a0016502820f325c39d71b236b2b39e0cb6 Mon Sep 17 00:00:00 2001 From: Andrew Or Date: Wed, 20 Aug 2014 15:09:33 -0700 Subject: [PATCH 1/2] Distinguish between unexpected output and no output at all --- python/pyspark/java_gateway.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/python/pyspark/java_gateway.py b/python/pyspark/java_gateway.py index c7f7c1fe591b0..d7331513ec3c5 100644 --- a/python/pyspark/java_gateway.py +++ b/python/pyspark/java_gateway.py @@ -54,12 +54,18 @@ def preexec_func(): gateway_port = proc.stdout.readline() gateway_port = int(gateway_port) except ValueError: + # Grab the remaining lines of stdout (stdout, _) = proc.communicate() exit_code = proc.poll() error_msg = "Launching GatewayServer failed" error_msg += " with exit code %d! " % exit_code if exit_code else "! " - error_msg += "(Warning: unexpected output detected.)\n\n" - error_msg += gateway_port + stdout + if gateway_port == "" and stdout == "": + error_msg += "(Warning: no output detected.)\n" + else: + error_msg += "(Warning: unexpected output detected.)\n\n" + error_msg += "--------------------------------------------------------------\n" + error_msg += gateway_port + stdout + error_msg += "--------------------------------------------------------------\n" raise Exception(error_msg) # Create a thread to echo output from the GatewayServer, which is required From 742f82311b1733f735fb5c2369aea7d1ca1d8774 Mon Sep 17 00:00:00 2001 From: Andrew Or Date: Wed, 20 Aug 2014 15:55:07 -0700 Subject: [PATCH 2/2] Further clarify warning messages --- python/pyspark/java_gateway.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/python/pyspark/java_gateway.py b/python/pyspark/java_gateway.py index d7331513ec3c5..6f4f62f23bc4d 100644 --- a/python/pyspark/java_gateway.py +++ b/python/pyspark/java_gateway.py @@ -58,11 +58,12 @@ def preexec_func(): (stdout, _) = proc.communicate() exit_code = proc.poll() error_msg = "Launching GatewayServer failed" - error_msg += " with exit code %d! " % exit_code if exit_code else "! " + error_msg += " with exit code %d!\n" % exit_code if exit_code else "!\n" + error_msg += "Warning: Expected GatewayServer to output a port, but found " if gateway_port == "" and stdout == "": - error_msg += "(Warning: no output detected.)\n" + error_msg += "no output.\n" else: - error_msg += "(Warning: unexpected output detected.)\n\n" + error_msg += "the following:\n\n" error_msg += "--------------------------------------------------------------\n" error_msg += gateway_port + stdout error_msg += "--------------------------------------------------------------\n"