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

    https://github.com/apache/spark/pull/16178#discussion_r91190778
  
    --- Diff: core/src/main/scala/org/apache/spark/SparkContext.scala ---
    @@ -1760,25 +1760,24 @@ class SparkContext(config: SparkConf) extends 
Logging {
       def listJars(): Seq[String] = addedJars.keySet.toSeq
     
       /**
    -   * Shut down the SparkContext.
    +   * When stopping SparkContext inside Spark components, it's easy to 
cause dead-lock since Spark
    +   * may wait for some internal threads to finish. It's better to use this 
method to stop
    +   * SparkContext instead.
        */
    -  def stop(): Unit = {
    -    if (env.rpcEnv.isInRPCThread) {
    -      // `stop` will block until all RPC threads exit, so we cannot call 
stop inside a RPC thread.
    -      // We should launch a new thread to call `stop` to avoid dead-lock.
    -      new Thread("stop-spark-context") {
    -        setDaemon(true)
    +  private[spark] def stopInNewThread(): Unit = {
    +    new Thread("stop-spark-context") {
    +      setDaemon(true)
     
    -        override def run(): Unit = {
    -          _stop()
    -        }
    -      }.start()
    -    } else {
    -      _stop()
    -    }
    +      override def run(): Unit = {
    +        SparkContext.this.stop()
    --- End diff --
    
    Will this ever throw an exception?  Should we register an 
`UncaughtExceptionHandler` or try catch with logging?


---
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 infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org

Reply via email to