diff options
author | Matei Zaharia <matei@eecs.berkeley.edu> | 2013-09-02 18:38:12 -0700 |
---|---|---|
committer | Matei Zaharia <matei@eecs.berkeley.edu> | 2013-09-02 18:38:12 -0700 |
commit | a106ed8b97e707b36818c11d1d7211fa28636178 (patch) | |
tree | 5ce12b04c710bd8e776c31bc3c8cef63f3313622 /python/pyspark/java_gateway.py | |
parent | 2ce200bf7f7a38afbcacf3303ca2418e49bdbe2a (diff) | |
parent | 59218bdd4996a13116009e3669b1b875be23a694 (diff) | |
download | spark-a106ed8b97e707b36818c11d1d7211fa28636178.tar.gz spark-a106ed8b97e707b36818c11d1d7211fa28636178.tar.bz2 spark-a106ed8b97e707b36818c11d1d7211fa28636178.zip |
Merge remote-tracking branch 'old/master'
Diffstat (limited to 'python/pyspark/java_gateway.py')
-rw-r--r-- | python/pyspark/java_gateway.py | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/python/pyspark/java_gateway.py b/python/pyspark/java_gateway.py index 26fbe0f080..e615c1e9b6 100644 --- a/python/pyspark/java_gateway.py +++ b/python/pyspark/java_gateway.py @@ -18,6 +18,7 @@ import os import sys import signal +import platform from subprocess import Popen, PIPE from threading import Thread from py4j.java_gateway import java_import, JavaGateway, GatewayClient @@ -29,12 +30,18 @@ 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, "spark-class"), "py4j.GatewayServer", + on_windows = platform.system() == "Windows" + script = "spark-class.cmd" if on_windows else "spark-class" + command = [os.path.join(SPARK_HOME, script), "py4j.GatewayServer", "--die-on-broken-pipe", "0"] - # 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) + if not on_windows: + # Don't send ctrl-c / SIGINT to the Java gateway: + def preexec_func(): + signal.signal(signal.SIGINT, signal.SIG_IGN) + proc = Popen(command, stdout=PIPE, stdin=PIPE, preexec_fn=preexec_func) + else: + # preexec_fn not supported on Windows + proc = Popen(command, stdout=PIPE, stdin=PIPE) # 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 |