From 7c6e71f05f4f5e0cd2d038ee81d1cda4a3e5cb39 Mon Sep 17 00:00:00 2001
From: Matthew Farrellee <matt@redhat.com>
Date: Wed, 3 Sep 2014 19:37:37 -0700
Subject: [PATCH] [SPARK-2435] Add shutdown hook to pyspark

Author: Matthew Farrellee <matt@redhat.com>

Closes #2183 from mattf/SPARK-2435 and squashes the following commits:

ee0ee99 [Matthew Farrellee] [SPARK-2435] Add shutdown hook to pyspark
---
 python/pyspark/shell.py | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/python/pyspark/shell.py b/python/pyspark/shell.py
index e1e7cd9541..fde3c29e5e 100644
--- a/python/pyspark/shell.py
+++ b/python/pyspark/shell.py
@@ -28,6 +28,7 @@ if sys.version_info[0] != 2:
     sys.exit(1)
 
 
+import atexit
 import os
 import platform
 import pyspark
@@ -42,6 +43,7 @@ if os.environ.get("SPARK_EXECUTOR_URI"):
     SparkContext.setSystemProperty("spark.executor.uri", os.environ["SPARK_EXECUTOR_URI"])
 
 sc = SparkContext(appName="PySparkShell", pyFiles=add_files)
+atexit.register(lambda: sc.stop())
 
 print("""Welcome to
       ____              __
-- 
GitLab