Skip to content

Commit 7c6e71f

Browse files
Matthew FarrelleeJoshRosen
authored andcommitted
[SPARK-2435] Add shutdown hook to pyspark
Author: Matthew Farrellee <[email protected]> Closes #2183 from mattf/SPARK-2435 and squashes the following commits: ee0ee99 [Matthew Farrellee] [SPARK-2435] Add shutdown hook to pyspark
1 parent c5cbc49 commit 7c6e71f

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

python/pyspark/shell.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
sys.exit(1)
2929

3030

31+
import atexit
3132
import os
3233
import platform
3334
import pyspark
@@ -42,6 +43,7 @@
4243
SparkContext.setSystemProperty("spark.executor.uri", os.environ["SPARK_EXECUTOR_URI"])
4344

4445
sc = SparkContext(appName="PySparkShell", pyFiles=add_files)
46+
atexit.register(lambda: sc.stop())
4547

4648
print("""Welcome to
4749
____ __

0 commit comments

Comments
 (0)