Github user heary-cao commented on a diff in the pull request:

    https://github.com/apache/spark/pull/23151#discussion_r237333755
  
    --- Diff: core/src/test/scala/org/apache/spark/SparkFunSuite.scala ---
    @@ -105,5 +105,16 @@ abstract class SparkFunSuite
           logInfo(s"\n\n===== FINISHED $shortSuiteName: '$testName' =====\n")
         }
       }
    -
    +  /**
    +   * Creates a temporary directory, which is then passed to `f` and will 
be deleted after `f`
    +   * returns.
    +   *
    +   * @todo Probably this method should be moved to a more general place
    +   */
    +  protected def withCreateTempDir(f: File => Unit): Unit = {
    --- End diff --
    
    Currently, `withTempDir` and `withCreateTempDir ` are somewhat different.
    **withTempDir**
    ```
    protected def withTempDir(f: File => Unit): Unit = {
        val dir = Utils.createTempDir().getCanonicalFile
        try f(dir) finally {
          // wait for all tasks to finish before deleting files
          waitForTasksToFinish()
          Utils.deleteRecursively(dir)
        }
      }
    
    protected def waitForTasksToFinish(): Unit = {
        eventually(timeout(10.seconds)) {
          assert(spark.sparkContext.statusTracker
            .getExecutorInfos.map(_.numRunningTasks()).sum == 0)
        }
      }
    ```
    **withCreateTempDir**
    ```
    protected def withCreateTempDir(f: File => Unit): Unit = {
        val dir = Utils.createTempDir()
        try f(dir) finally {
          Utils.deleteRecursively(dir)
        }
      }
    ```
    thanks.


---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org

Reply via email to