如何检查SparkContext已停止? [英] How to check that the SparkContext has been stopped?

查看:219
本文介绍了如何检查SparkContext已停止?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何检测 SparkContext 是否已已停止?

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已停止?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆