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

    https://github.com/apache/spark/pull/5560#discussion_r28720894
  
    --- Diff: core/src/main/scala/org/apache/spark/util/Utils.scala ---
    @@ -2132,6 +2136,93 @@ private[spark] object Utils extends Logging {
           .getOrElse(UserGroupInformation.getCurrentUser().getShortUserName())
       }
     
    +  /**
    +   * Adds a shutdown hook with default priority.
    +   */
    +  def addShutdownHook(hook: () => Unit): AnyRef = {
    +    addShutdownHook(DEFAULT_SHUTDOWN_PRIORITY, hook)
    +  }
    +
    +  /**
    +   * Adds a shutdown hook with the given priority. Hooks with lower 
priority values run
    +   * first.
    +   */
    +  def addShutdownHook(priority: Int, hook: () => Unit): AnyRef = {
    +    shutdownHooks.add(priority, hook)
    +  }
    +
    +  /**
    +   * Remove a previously installed shutdown hook.
    +   */
    +  def removeShutdownHook(ref: AnyRef): Boolean = {
    +    shutdownHooks.remove(ref)
    +  }
    +
    +}
    +
    +private [util] class SparkShutdownHookManager {
    +
    +  private val hooks = new PriorityQueue[SparkShutdownHook]()
    +  private var shuttingDown = false
    --- End diff --
    
    Yeah, 3 of the 4 uses of `inShutdown` look like they could be replaced 
easily without risk. But one controls calling `System.exit` in an uncaught 
exception handler, which apparently deadlocks when actually in JVM shutdown. 
Darn. Unless you have a bright idea about working around that I don't know if 
we can co-opt and replace use of `Utils.inShutdown`


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