Skip to content

Commit

Permalink
Fix send-log-in-developer-console stuff
Browse files Browse the repository at this point in the history
Logs were sent only when the session was being created, not after that
  • Loading branch information
alexarchambault committed Jun 29, 2023
1 parent bc97612 commit e8b2591
Showing 1 changed file with 14 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,12 @@ import almond.display.Display.html
import ammonite.interp.api.InterpAPI
import ammonite.repl.api.ReplAPI
import org.apache.log4j.{Category, Logger, RollingFileAppender}
import org.apache.spark.scheduler.{SparkListener, SparkListenerApplicationEnd}
import org.apache.spark.sql.SparkSession
import org.apache.spark.sql.ammonitesparkinternals.AmmoniteSparkSessionBuilder

import scala.collection.JavaConverters._
import scala.util.control.NonFatal

class NotebookSparkSessionBuilder(implicit
interpApi: InterpAPI,
Expand Down Expand Up @@ -102,10 +104,20 @@ class NotebookSparkSessionBuilder(implicit
new ProgressSparkListener(session, keep0, progress0, useBars0)
)

session.sparkContext.addSparkListener(
new SparkListener {
override def onApplicationEnd(applicationEnd: SparkListenerApplicationEnd) =
sendLogOpt.foreach(_.stop())
}
)

session
}
finally
sendLogOpt.foreach(_.stop())
catch {
case NonFatal(e) =>
sendLogOpt.foreach(_.stop())
throw e
}
}

}

0 comments on commit e8b2591

Please sign in to comment.