aboutsummaryrefslogtreecommitdiff
path: root/core/src
diff options
context:
space:
mode:
Diffstat (limited to 'core/src')
-rw-r--r--core/src/main/scala/org/apache/spark/SparkContext.scala7
1 files changed, 7 insertions, 0 deletions
diff --git a/core/src/main/scala/org/apache/spark/SparkContext.scala b/core/src/main/scala/org/apache/spark/SparkContext.scala
index 40189a2256..eb13686f26 100644
--- a/core/src/main/scala/org/apache/spark/SparkContext.scala
+++ b/core/src/main/scala/org/apache/spark/SparkContext.scala
@@ -2489,6 +2489,13 @@ object SparkContext extends Logging {
}
}
+ /** Return the current active [[SparkContext]] if any. */
+ private[spark] def getActive: Option[SparkContext] = {
+ SPARK_CONTEXT_CONSTRUCTOR_LOCK.synchronized {
+ Option(activeContext.get())
+ }
+ }
+
/**
* Called at the beginning of the SparkContext constructor to ensure that no SparkContext is
* running. Throws an exception if a running context is detected and logs a warning if another