Github user JoshRosen commented on a diff in the pull request:
https://github.com/apache/spark/pull/2259#discussion_r17268480
--- Diff:
core/src/main/scala/org/apache/spark/api/python/PythonWorkerFactory.scala ---
@@ -199,9 +207,47 @@ private[spark] class PythonWorkerFactory(pythonExec:
String, envVars: Map[String
}
}
+ /**
+ * Monitor all the idle workers, kill them after timeout.
+ */
+ private class MonitorThread extends Thread(s"Idle Worker Monitor for
$pythonExec") {
+
+ setDaemon(true)
+
+ override def run() {
+ while (true) {
+ idleWorkers.synchronized {
+ if (lastActivity + IDLE_WORKER_TIMEOUT_MS <
System.currentTimeMillis()) {
+ while (idleWorkers.length > 0) {
+ val worker = idleWorkers.dequeue()
+ try {
+ // the Python worker will exit after closing the socket
+ worker.close()
+ } catch {
+ case e: Exception =>
+ logWarning("Failed to close worker socket", e)
+ }
+ }
+ lastActivity = System.currentTimeMillis()
+ }
+ }
+ Thread.sleep(10000)
--- End diff --
It looks like we sleep for 10 seconds here, so I guess it will take 10
seconds to detect an idle worker instead of IDLE_WORKER_TIMEOUT_MS.
---
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]