Skip to content

Commit

Permalink
Distinguish between unexpected output and no output at all
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewor14 committed Aug 20, 2014
1 parent c1ba4cd commit e96a7a0
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions python/pyspark/java_gateway.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit e96a7a0

Please sign in to comment.