Github user tdas commented on a diff in the pull request:

    https://github.com/apache/spark/pull/8080#discussion_r36710304
  
    --- Diff: python/pyspark/streaming/context.py ---
    @@ -170,6 +173,48 @@ def getOrCreate(cls, checkpointPath, setupFunc):
             cls._transformerSerializer.ctx = sc
             return StreamingContext(sc, None, jssc)
     
    +    @classmethod
    +    def getActive(cls):
    +        """
    +        Return either the currently active StreamingContext (i.e., if 
there is a context started
    +        but not stopped) or None.
    +        """
    +        activePythonContext = cls._activeContext
    +        if activePythonContext is not None:
    +            # Verify that the current running Java StreamingContext is 
active and is the same one
    +            # backing the supposedly active Python context
    +            activePythonContextJavaId = 
activePythonContext._jssc.ssc().hashCode()
    +            activeJvmContextOption = 
activePythonContext._jvm.StreamingContext.getActive()
    +            if activeJvmContextOption.isEmpty() or \
    +                    activeJvmContextOption.get().hashCode() != 
activePythonContextJavaId:
    --- End diff --
    
    Yeah, I was on the fence about what to do here. Thanks for deciding for me.


---
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]

Reply via email to