[ https://issues.apache.org/jira/browse/SPARK-3458?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17293383#comment-17293383 ]
Apache Spark commented on SPARK-3458: ------------------------------------- User 'LuciferYang' has created a pull request for this issue: https://github.com/apache/spark/pull/31698 > enable use of python's "with" statements for SparkContext management > -------------------------------------------------------------------- > > Key: SPARK-3458 > URL: https://issues.apache.org/jira/browse/SPARK-3458 > Project: Spark > Issue Type: New Feature > Components: PySpark > Reporter: Matthew Farrellee > Assignee: Matthew Farrellee > Priority: Major > Labels: features, python, sparkcontext > Fix For: 1.2.0 > > > best practice for managing SparkContexts involves exception handling, e.g. > {code} > try: > sc = SparkContext() > app(sc) > finally: > sc.stop() > {code} > python provides the "with" statement to simplify this code, e.g. > {code} > with SparkContext() as sc: > app(sc) > {code} > the SparkContext should be usable in a "with" statement -- This message was sent by Atlassian Jira (v8.3.4#803005) --------------------------------------------------------------------- To unsubscribe, e-mail: issues-unsubscr...@spark.apache.org For additional commands, e-mail: issues-h...@spark.apache.org