diff options
author | Josh Rosen <joshrosen@eecs.berkeley.edu> | 2013-08-28 16:39:44 -0700 |
---|---|---|
committer | Josh Rosen <joshrosen@eecs.berkeley.edu> | 2013-08-28 16:39:44 -0700 |
commit | 742c44eae693d2bde76259043c962e416691258c (patch) | |
tree | a340a7752e86be026572aeb8732685be21ec2a43 /python | |
parent | 898da7e42221572884e915545d248bad058ae915 (diff) | |
download | spark-742c44eae693d2bde76259043c962e416691258c.tar.gz spark-742c44eae693d2bde76259043c962e416691258c.tar.bz2 spark-742c44eae693d2bde76259043c962e416691258c.zip |
Don't send SIGINT to Py4J gateway subprocess.
This addresses SPARK-885, a usability issue where PySpark's
Java gateway process would be killed if the user hit ctrl-c.
Note that SIGINT still won't cancel the running s
This fix is based on http://stackoverflow.com/questions/5045771
Diffstat (limited to 'python')
-rw-r--r-- | python/pyspark/java_gateway.py | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/python/pyspark/java_gateway.py b/python/pyspark/java_gateway.py index e503fb7621..fdc9851479 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 @@ -30,7 +31,10 @@ def launch_gateway(): # proper classpath and SPARK_MEM settings from spark-env.sh command = [os.path.join(SPARK_HOME, "run"), "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 |