Spenserrrr commented on code in PR #59976:
URL: https://github.com/apache/spark/pull/59976#discussion_r4531353631
##########
core/src/main/scala/org/apache/spark/api/python/PythonRunner.scala:
##########
@@ -553,6 +553,27 @@ private[spark] object BasePythonRunner extends Logging {
}
}
+ private[python] case class InitResponse(
+ error: Option[PythonWorkerInitError],
+ receivedAtMs: Long)
+
+ private[python] def readInitResponseFrame(stream: DataInputStream):
InitResponse = {
+ stream.readInt() match {
+ case SpecialLengths.START_OF_INIT_RESPONSE =>
+ val error = readInitResponse(stream)
+ InitResponse(error, System.currentTimeMillis())
+ case other =>
+ throw SparkException.internalError(
+ s"Expected the Python worker init response, but got $other")
+ }
+ }
+
+ private[python] class PythonWorkerInputStream(
+ input: InputStream,
+ receiveInit: DataInputStream => InitResponse) extends
DataInputStream(input) {
+ lazy val initResponse: Try[InitResponse] = Try(receiveInit(this))
Review Comment:
I removed PythonWorkerInputStream and its callback. Now DataInputStream
handles I/O and ReaderIterator owns initialization and caches the result.
--
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]