itskals commented on code in PR #52091:
URL: https://github.com/apache/spark/pull/52091#discussion_r2297237630


##########
core/src/main/scala/org/apache/spark/deploy/SparkSubmit.scala:
##########
@@ -1037,6 +1045,12 @@ private[spark] class SparkSubmit extends Logging {
           case e: Throwable => logError("Failed to close SparkContext", e)
         }
       }
+      if (sparkConf.get(SUBMIT_CALL_SYSTEM_EXIT_ON_MAIN_EXIT)) {
+        logInfo(
+          log"Calling System.exit() with exit code ${MDC(LogKeys.EXIT_CODE, 
exitCode)} " +
+          log"because main ${MDC(LogKeys.CONFIG, 
SUBMIT_CALL_SYSTEM_EXIT_ON_MAIN_EXIT.key)}=true")
+        exitFn(exitCode)

Review Comment:
   Something like this:
   
   `.....
   if (forceTerminateJVM) {
             createAndStartShutdownThread(timeToWaitInSeconds, exitCode)
           }
    }
           
      def createAndStartShutdownThread(timeToWaitInSeconds: Long, exitCode: 
Int): Unit = {
       logInfo("Starting the shutdown thread")
       val shutdownThread = new Thread(new Runnable {
         override def run(): Unit = {
           logInfo(s"Shutdown thread will wait for ${timeToWaitInSeconds}s 
before " +
             s"exiting the JVM")
           Thread.sleep(TimeUnit.SECONDS.toMillis(timeToWaitInSeconds))
           logWarning("There are non-daemon threads preventing this JVM from 
shutting down")
           Thread.getAllStackTraces.keySet().asScala.filter(t => !t.isDaemon && 
t.isAlive).
             foreach(t => {
               logWarning(s"== ${t.toString} ==")
               logWarning(t.getStackTrace().mkString(""))
             })
           logWarning(s"Stopping the JVM with System.exit(${exitCode})")
           System.exit(exitCode)
         }
       }, "JVMShutdownThread")
       shutdownThread.setDaemon(true)
       shutdownThread.start()
     }       
           `



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to