Skip to content

Commit

Permalink
shutdown Py4JServer
Browse files Browse the repository at this point in the history
  • Loading branch information
cfmcgrady committed Mar 31, 2023
1 parent d9e14f2 commit cdc9630
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ package org.apache.kyuubi.engine.spark.session
import java.util.concurrent.{ScheduledExecutorService, TimeUnit}

import org.apache.hive.service.rpc.thrift.TProtocolVersion
import org.apache.spark.api.python.KyuubiPythonGatewayServer
import org.apache.spark.sql.SparkSession

import org.apache.kyuubi.KyuubiSQLException
Expand Down Expand Up @@ -94,6 +95,7 @@ class SparkSQLSessionManager private (name: String, spark: SparkSession)

override def stop(): Unit = {
super.stop()
KyuubiPythonGatewayServer.shutdown()
userIsolatedSparkSessionThread.foreach(_.shutdown())
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,12 @@ object KyuubiPythonGatewayServer extends Logging {

val CONNECTION_FILE_PATH = Utils.createTempDir() + "/connection.info"

private var gatewayServer: Py4JServer = _

def start(): Unit = {

val sparkConf = new SparkConf()
val gatewayServer: Py4JServer = new Py4JServer(sparkConf)
gatewayServer = new Py4JServer(sparkConf)

gatewayServer.start()
val boundPort: Int = gatewayServer.getListeningPort
Expand Down Expand Up @@ -65,4 +67,11 @@ object KyuubiPythonGatewayServer extends Logging {
System.exit(1)
}
}

def shutdown(): Unit = {
if (gatewayServer != null) {
logInfo("shutting down the python gateway server.")
gatewayServer.shutdown()
}
}
}

0 comments on commit cdc9630

Please sign in to comment.