Github user zsxwing commented on a diff in the pull request:

    https://github.com/apache/spark/pull/9264#discussion_r47190819
  
    --- Diff: 
core/src/test/scala/org/apache/spark/rdd/AsyncRDDActionsSuite.scala ---
    @@ -197,4 +197,34 @@ class AsyncRDDActionsSuite extends SparkFunSuite with 
BeforeAndAfterAll with Tim
           Await.result(f, Duration(20, "milliseconds"))
         }
       }
    +
    +  private def testAsyncAction[R](action: RDD[Int] => FutureAction[R]): 
Unit = {
    +    val executionContextInvoked = Promise[Unit]
    +    val fakeExecutionContext = new ExecutionContext {
    +      override def execute(runnable: Runnable): Unit = {
    +        executionContextInvoked.success(())
    +      }
    +      override def reportFailure(t: Throwable): Unit = ()
    +    }
    +    val starter = Smuggle(new Semaphore(0))
    +    starter.drainPermits()
    +    val rdd = sc.parallelize(1 to 100, 4).mapPartitions {itr => 
starter.acquire(1); itr}
    +    val f = action(rdd)
    +    f.onComplete(_ => ())(fakeExecutionContext)
    +    // Here we verify that registering the callback didn't cause a thread 
to be consumed.
    +    assert(!executionContextInvoked.isCompleted)
    +    // Now allow the executors to proceed with task processing.
    +    starter.release(rdd.partitions.length)
    +    // Waiting for the result verifies that the tasks were successfully 
processed.
    +    // This mainly exists to verify that we didn't break task 
deserialization.
    --- End diff --
    
    Just tested the logic locally. `Task not serializable` will be throw from 
`mapPartitions` if I added some non-serializable reference to the closure. 
    
    Since no place will call `executionContextInvoked.failure`, the only 
exception will be thrown from `Await.result(executionContextInvoked.future, 
atMost = 15.seconds)` is just TimeoutException.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to