From 134bc267a5ef01d9dea3d08cc255facdd8dfc0c8 Mon Sep 17 00:00:00 2001 From: Takuya UESHIN Date: Fri, 8 Sep 2017 11:34:41 +0900 Subject: [PATCH] Make pyspark.sql.tests.SQLTests2 stop SparkContext. --- python/pyspark/sql/tests.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/python/pyspark/sql/tests.py b/python/pyspark/sql/tests.py index 3d87ccfc03dd..1bc889c3f45c 100644 --- a/python/pyspark/sql/tests.py +++ b/python/pyspark/sql/tests.py @@ -2619,8 +2619,12 @@ def test_sparksession_with_stopped_sparkcontext(self): self.sc.stop() sc = SparkContext('local[4]', self.sc.appName) spark = SparkSession.builder.getOrCreate() - df = spark.createDataFrame([(1, 2)], ["c", "c"]) - df.collect() + try: + df = spark.createDataFrame([(1, 2)], ["c", "c"]) + df.collect() + finally: + spark.stop() + sc.stop() class UDFInitializationTests(unittest.TestCase):