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: [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]