Skip to content
Snippets Groups Projects
Commit fd898359 authored by Matei Zaharia's avatar Matei Zaharia
Browse files

Merge pull request #870 from JoshRosen/spark-885

Don't send SIGINT / ctrl-c to Py4J gateway subprocess
parents 618f0ecb 742c44ea
No related branches found
No related tags found
No related merge requests found
......@@ -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, "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
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment