craiuconstantintiberiu commented on code in PR #51684:
URL: https://github.com/apache/spark/pull/51684#discussion_r2244236603


##########
core/src/test/scala/org/apache/spark/api/python/PythonWorkerFactorySuite.scala:
##########
@@ -33,6 +33,12 @@ import org.apache.spark.util.ThreadUtils
 // Tests for PythonWorkerFactory.
 class PythonWorkerFactorySuite extends SparkFunSuite with SharedSparkContext {
 
+  private def getIdleWorkerCount(factory: PythonWorkerFactory): Int = {
+    val field = factory.getClass.getDeclaredField("idleWorkers")

Review Comment:
   Thank you, changed to `private[spark]` and added comment.



##########
core/src/main/scala/org/apache/spark/api/python/PythonWorkerFactory.scala:
##########
@@ -484,6 +486,15 @@ private[spark] class PythonWorkerFactory(
       self.synchronized {
         lastActivityNs = System.nanoTime()
         idleWorkers.enqueue(worker)
+        if (idleWorkerPoolSize.exists(idleWorkers.size > _)) {
+          val oldestWorker = idleWorkers.dequeue()
+          try {
+            oldestWorker.stop()

Review Comment:
   Thanks, fixed.



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

Reply via email to