zhztheplayer commented on code in PR #11002:
URL: 
https://github.com/apache/incubator-gluten/pull/11002#discussion_r2485866406


##########
gluten-core/src/main/scala/org/apache/spark/util/SparkDirectoryUtil.scala:
##########
@@ -37,14 +37,22 @@ class SparkDirectoryUtil private (val roots: Array[String]) 
extends Logging {
     rootDir =>
       try {
         val localDir = Utils.createDirectory(rootDir, "gluten")
-        SparkShutdownManagerUtil.addHookForTempDirRemoval(
-          () => {
-            try FileUtils.forceDelete(localDir)
-            catch {
-              case e: Exception =>
-                throw new GlutenException(e)
-            }
-          })
+        try {
+          SparkShutdownManagerUtil.addHookForTempDirRemoval(
+            () => {
+              try FileUtils.forceDelete(localDir)
+              catch {
+                case e: Exception =>
+                  throw new GlutenException(e)
+              }
+            })
+        } catch {
+          case _: IllegalStateException =>
+            // Shutdown hooks cannot be modified during shutdown. If the 
Gluten plugin
+            // is being initialized during Spark context shutdown we can 
safely ignore
+            // the hook registration since cleanup is not critical during 
shutdown.
+            logWarning(s"Cannot register shutdown hook for $localDir")

Review Comment:
   Can we log `ise.getMessage` here? Thanks.



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