Ngone51 commented on code in PR #49413: URL: https://github.com/apache/spark/pull/49413#discussion_r1916531539
########## core/src/main/scala/org/apache/spark/TaskContextImpl.scala: ########## @@ -296,4 +304,39 @@ private[spark] class TaskContextImpl( private[spark] override def fetchFailed: Option[FetchFailedException] = _fetchFailedException private[spark] override def getLocalProperties: Properties = localProperties + + + override def interruptible(): Boolean = TaskContext.synchronized(_interruptible) + + override def pendingInterrupt(threadToInterrupt: Option[Thread], reason: String): Unit = { + TaskContext.synchronized { + pendingInterruptRequest = Some((threadToInterrupt, reason)) + } + } + + def createResourceUninterruptibly[T <: Closeable](resourceBuilder: => T): T = { + + @inline def interruptIfRequired(): Unit = { + pendingInterruptRequest.foreach { case (threadToInterrupt, reason) => + markInterrupted(reason) + threadToInterrupt.foreach(_.interrupt()) + } + killTaskIfInterrupted() + } + + TaskContext.synchronized { + interruptIfRequired() Review Comment: No. This is for the case where resource creation happens after the task has been marked as `interrupted`. In that case, `pendingInterruptRequest` is `None` and `reasonIfKilled` is not `None`, and `killTaskIfInterrupted()` would throw `TaskKilledException()` to stop the task thread. -- 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: reviews-unsubscr...@spark.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org