Skip to content
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 "! "
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unrelated to your change but can you fix this too while you're at it? Looks like there's an extra "!" when there's no exit code

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wait, when there's no exit code it looks like this, no?

Launching GatewayServer failed! (Warning: ...)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OH sorry misread this -- thought the "if" was for what to substitute. NVM.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I misread it too the first time after reading your comment :)

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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be more descriptive? Like "Expected GatewayServer to output a port; found: " (otherwise I wonder if printing gateway_port + stdout will seem cryptic to people)

error_msg += "--------------------------------------------------------------\n"
raise Exception(error_msg)

# Create a thread to echo output from the GatewayServer, which is required
Expand Down