Skip to content

Commit

Permalink
[LIVY-995][REPL] JsonParseException is thrown when closing Livy sessi…
Browse files Browse the repository at this point in the history
…on when using python profile
  • Loading branch information
jianzhenwu committed Jan 18, 2024
1 parent 86fc823 commit 2e0e7a5
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions repl/src/main/scala/org/apache/livy/repl/PythonInterpreter.scala
Original file line number Diff line number Diff line change
Expand Up @@ -269,11 +269,21 @@ private class PythonInterpreter(
}

override protected def sendShutdownRequest(): Unit = {
sendRequest(Map(
stdin.println(write(Map(
"msg_type" -> "shutdown_request",
"content" -> ()
)).foreach { case rep =>
warn(f"process failed to shut down while returning $rep")
)))
stdin.flush()

// Pyspark prints profile info to stdout when enabling spark.python.profile. see SPARK-37443
var lines = Seq[String]()
var line = stdout.readLine()
while(line != null) {
lines :+= line
line = stdout.readLine()
}
if (lines.nonEmpty) {
warn(f"python process shut down while returning ${lines.mkString("\n")}")
}
}

Expand Down

0 comments on commit 2e0e7a5

Please sign in to comment.