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

    https://github.com/apache/spark/pull/4238#discussion_r23717122
  
    --- Diff: core/src/main/scala/org/apache/spark/api/python/PythonRDD.scala 
---
    @@ -67,17 +67,16 @@ private[spark] class PythonRDD(
           envVars += ("SPARK_REUSE_WORKER" -> "1")
         }
         val worker: Socket = env.createPythonWorker(pythonExec, envVars.toMap)
    +    // Whether is the worker released into idle pool
    +    var released = false
     
         // Start a thread to feed the process input from our parent's iterator
         val writerThread = new WriterThread(env, worker, split, context)
     
    -    var complete_cleanly = false
         context.addTaskCompletionListener { context =>
           writerThread.shutdownOnTaskCompletion()
           writerThread.join()
    -      if (reuse_worker && complete_cleanly) {
    -        env.releasePythonWorker(pythonExec, envVars.toMap, worker)
    -      } else {
    +      if (!released) {
    --- End diff --
    
    I think the old version of this logic was slightly easier to understand 
since the variable names made it clear that we _always_ close the worker if 
worker re-use is disabled and that we _might_ close the worker if it didn't 
exit cleanly.
    
    To make this more clear in the updated code, I propose that we modify this 
conditional to say `if (!reuse_worker || !released)` and maybe add a comment 
(or change `released` back to `compete_cleanly`).


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