Skip to content

Commit ee0ee99

Browse files
author
Matthew Farrellee
committed
[SPARK-2435] Add shutdown hook to pyspark
1 parent 76e3ba4 commit ee0ee99

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)