Github user JoshRosen commented on a diff in the pull request:
https://github.com/apache/spark/pull/5907#discussion_r29689186
--- Diff:
streaming/src/main/scala/org/apache/spark/streaming/StreamingContext.scala ---
@@ -607,8 +614,27 @@ class StreamingContext private[streaming] (
*/
object StreamingContext extends Logging {
+ /**
+ * Lock that guards access to global variables that track active
StreamingContext.
+ */
+ private val ACTIVATION_LOCK = new Object()
- private[streaming] val DEFAULT_CLEANER_TTL = 3600
+ private var activeContext: AtomicReference[StreamingContext] =
+ new AtomicReference[StreamingContext](null)
+
+ private def assertNoOtherContextIsActive(): Unit = {
+ ACTIVATION_LOCK.synchronized {
+ if (activeContext.get() != null) {
+ throw new SparkException("Only one StreamingContext may be started
in this JVM")
--- End diff --
Also, I think that core has some logic to print the call site of the active
context in the error message, which can sometimes be a useful debugging aid
when determining where contexts are being leaked.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]