How do I detect whether the SparkContext has been stopped?推荐答案 这适用于在编写该时间的Scala/Java API 在Spark发布1.6版之前,您将无法对其进行检查,而只能对其进行触发:Before Spark has released version 1.6, you wouldn't be able to check it, but only to trigger it: sc.stop() 从1.6版及更高版本开始,您有一个布尔函数,如果上下文已停止或正在停止,则该布尔函数将返回true:From version 1.6 and above, you have a boolean function that returns true if context is stopped or in the midst of stopping: sc.isStopped 这适用于PySpark API 感谢@ zero323评论:Thanks for @zero323 comment: sc._jsc.sc().isStopped() 哪个为您提供了Java SparkContext.Which gives you the Java SparkContext. 这篇关于如何检查SparkContext已停止?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!
10-11 01:03