viirya commented on code in PR #60540:
URL: https://github.com/apache/spark/pull/60540#discussion_r4583920695
##########
core/src/main/scala/org/apache/spark/api/python/PythonRunner.scala:
##########
@@ -702,15 +703,53 @@ private[spark] object BasePythonRunner extends Logging {
}
/**
- * Throws a [[PythonWorkerException]] if `n`, the result of a read from
the worker, is the
- * end of the stream and the worker was killed because of the idle timeout.
+ * Runs `op`, which reads from the worker, and returns its result.
+ *
+ * If the read times out, which only a blocking socket with a read timeout
does, the idle
+ * timeout is handled and the read is tried again. Once the worker has
been killed because
+ * of the idle timeout, the end of the stream and a failure of the read
both throw a
+ * [[PythonWorkerException]] for the idle timeout: the connection of a
killed worker can be
+ * reset instead of closed, for example when the worker had unread input.
A failure of the
+ * read with no kill is thrown as is.
*/
- def throwIfKilled(n: Int): Unit = {
+ def read(op: => Int): Int = {
+ var n = 0
+ var done = false
+ while (!done) {
+ try {
+ n = op
+ done = true
+ } catch {
+ case _: SocketTimeoutException =>
+ onIdleTimeout(hasInputs = true)
Review Comment:
Filed SPARK-61775 for this.
--
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]