Skip to content
Snippets Groups Projects
Commit 2e572c41 authored by Ashwin Shankar's avatar Ashwin Shankar Committed by Davies Liu
Browse files

[SPARK-8170] [PYTHON] Add signal handler to trap Ctrl-C in pyspark and cancel all running jobs

This patch adds a signal handler to trap Ctrl-C and cancels running job.

Author: Ashwin Shankar <ashankar@netflix.com>

Closes #9033 from ashwinshankar77/master.
parent 149472a0
No related branches found
No related tags found
No related merge requests found
......@@ -19,6 +19,7 @@ from __future__ import print_function
import os
import shutil
import signal
import sys
from threading import Lock
from tempfile import NamedTemporaryFile
......@@ -217,6 +218,12 @@ class SparkContext(object):
else:
self.profiler_collector = None
# create a signal handler which would be invoked on receiving SIGINT
def signal_handler(signal, frame):
self.cancelAllJobs()
signal.signal(signal.SIGINT, signal_handler)
def _initialize_context(self, jconf):
"""
Initialize SparkContext in function to allow subclass specific initialization
......
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