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

    https://github.com/apache/spark/pull/20519#discussion_r167013866
  
    --- Diff: 
core/src/main/scala/org/apache/spark/api/python/PythonWorkerFactory.scala ---
    @@ -180,18 +181,52 @@ private[spark] class PythonWorkerFactory(pythonExec: 
String, envVars: Map[String
             return
           }
     
    +      var serverSocket: ServerSocket = null
           try {
    +        // get a server socket so that the launched daemon can tell us its 
server port
    +        serverSocket = new ServerSocket(0, 0, 
InetAddress.getByAddress(Array(127, 0, 0, 1)))
    +        val serverPort = serverSocket.getLocalPort
    +
    +        // generate an 'auth token' for the daemon to pass back to us. 
This will
    +        // allow us to confirm that the we are truly communicating with 
the newly
    +        // launched daemon
    +        val expectedAuthToken = (new Random()).nextInt()
    --- End diff --
    
    probably ok, but I'd use `SecureRandom`, just in case. Maybe even use a 
long for the token. Also the parentheses around `new` aren't necessary.


---

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

Reply via email to