aboutsummaryrefslogtreecommitdiff
path: root/python/pyspark/java_gateway.py
diff options
context:
space:
mode:
authorMatei Zaharia <matei@eecs.berkeley.edu>2013-09-01 14:57:27 -0700
committerMatei Zaharia <matei@eecs.berkeley.edu>2013-09-01 14:57:27 -0700
commit2ce200bf7f7a38afbcacf3303ca2418e49bdbe2a (patch)
tree586a62e61ad15b5eda60cb13e15ca0c66cb1cc31 /python/pyspark/java_gateway.py
parent87d586e4da63e6e1875d9cac194c6f11e1cdc653 (diff)
parentf957c26fa27486c329d82cb66595b2cf07aed0ef (diff)
downloadspark-2ce200bf7f7a38afbcacf3303ca2418e49bdbe2a.tar.gz
spark-2ce200bf7f7a38afbcacf3303ca2418e49bdbe2a.tar.bz2
spark-2ce200bf7f7a38afbcacf3303ca2418e49bdbe2a.zip
Merge remote-tracking branch 'old/master'
Diffstat (limited to 'python/pyspark/java_gateway.py')
-rw-r--r--python/pyspark/java_gateway.py12
1 files changed, 8 insertions, 4 deletions
diff --git a/python/pyspark/java_gateway.py b/python/pyspark/java_gateway.py
index e503fb7621..26fbe0f080 100644
--- a/python/pyspark/java_gateway.py
+++ b/python/pyspark/java_gateway.py
@@ -17,6 +17,7 @@
import os
import sys
+import signal
from subprocess import Popen, PIPE
from threading import Thread
from py4j.java_gateway import java_import, JavaGateway, GatewayClient
@@ -28,9 +29,12 @@ SPARK_HOME = os.environ["SPARK_HOME"]
def launch_gateway():
# Launch the Py4j gateway using Spark's run command so that we pick up the
# proper classpath and SPARK_MEM settings from spark-env.sh
- command = [os.path.join(SPARK_HOME, "run"), "py4j.GatewayServer",
+ command = [os.path.join(SPARK_HOME, "spark-class"), "py4j.GatewayServer",
"--die-on-broken-pipe", "0"]
- proc = Popen(command, stdout=PIPE, stdin=PIPE)
+ # Don't send ctrl-c / SIGINT to the Java gateway:
+ def preexec_function():
+ signal.signal(signal.SIGINT, signal.SIG_IGN)
+ proc = Popen(command, stdout=PIPE, stdin=PIPE, preexec_fn=preexec_function)
# Determine which ephemeral port the server started on:
port = int(proc.stdout.readline())
# Create a thread to echo output from the GatewayServer, which is required
@@ -49,7 +53,7 @@ def launch_gateway():
# Connect to the gateway
gateway = JavaGateway(GatewayClient(port=port), auto_convert=False)
# Import the classes used by PySpark
- java_import(gateway.jvm, "spark.api.java.*")
- java_import(gateway.jvm, "spark.api.python.*")
+ java_import(gateway.jvm, "org.apache.spark.api.java.*")
+ java_import(gateway.jvm, "org.apache.spark.api.python.*")
java_import(gateway.jvm, "scala.Tuple2")
return gateway