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

    https://github.com/apache/spark/pull/1643#discussion_r15731017
  
    --- Diff: 
core/src/main/scala/org/apache/spark/api/python/PythonWorkerFactory.scala ---
    @@ -189,19 +197,34 @@ private[spark] class PythonWorkerFactory(pythonExec: 
String, envVars: Map[String
     
       private def stopDaemon() {
         synchronized {
    -      // Request shutdown of existing daemon by sending SIGTERM
    -      if (daemon != null) {
    -        daemon.destroy()
    -      }
    +      if (useDaemon) {
    +        // Request shutdown of existing daemon by sending SIGTERM
    +        if (daemon != null) {
    +          daemon.destroy()
    +        }
     
    -      daemon = null
    -      daemonPort = 0
    +        daemon = null
    +        daemonPort = 0
    +      } else {
    +        simpleWorkers.mapValues(_.destroy())
    +      }
         }
       }
     
       def stop() {
         stopDaemon()
       }
    +
    +  def stopWorker(worker: Socket) {
    +    if (useDaemon) {
    +      daemonWorkers.get(worker).foreach {
    --- End diff --
    
    The other accesses of `daemonWorkers` are guarded by `synchronized` blocks; 
does this access also need synchronization?  It looks like calls to 
`stopWorker()` only occur from `destroyPythonWorker()`, which is synchronized 
using the SparkEnv object.  To be on the safe side, we should probably add 
`synchronized` here unless there's a good reason not to.


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