Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
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
5 changes: 3 additions & 2 deletions repl/src/main/resources/fake_shell.py
Original file line number Diff line number Diff line change
Expand Up @@ -576,14 +576,15 @@ def main():
from pyspark.context import SparkContext
from pyspark.sql import SQLContext, HiveContext, Row
# Connect to the gateway
gateway_host = os.environ["PYSPARK_GATEWAY_HOST"]
gateway_port = int(os.environ["PYSPARK_GATEWAY_PORT"])
try:
from py4j.java_gateway import GatewayParameters
gateway_secret = os.environ["PYSPARK_GATEWAY_SECRET"]
gateway = JavaGateway(gateway_parameters=GatewayParameters(
port=gateway_port, auth_token=gateway_secret, auto_convert=True))
address=gateway_host, port=gateway_port, auth_token=gateway_secret, auto_convert=True))
except:
gateway = JavaGateway(GatewayClient(port=gateway_port), auto_convert=True)
gateway = JavaGateway(GatewayClient(address=gateway_host, port=gateway_port), auto_convert=True)

# Import the classes used by PySpark
java_import(gateway.jvm, "org.apache.spark.SparkConf")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ object PythonInterpreter extends Logging {
env.put("PYSPARK_PYTHON", pythonExec)
env.put("PYTHONPATH", pythonPath.mkString(File.pathSeparator))
env.put("PYTHONUNBUFFERED", "YES")
env.put("PYSPARK_GATEWAY_HOST", gatewayServer.getAddress.getHostAddress)
env.put("PYSPARK_GATEWAY_PORT", "" + gatewayServer.getListeningPort)
env.put("PYSPARK_GATEWAY_SECRET", secretKey)
env.put("SPARK_HOME", sys.env.getOrElse("SPARK_HOME", "."))
Expand Down