shuiqiangchen commented on a change in pull request #12165:
URL: https://github.com/apache/flink/pull/12165#discussion_r426329242



##########
File path: 
flink-python/src/main/java/org/apache/flink/client/python/PythonDriver.java
##########
@@ -95,23 +104,36 @@ public static void main(String[] args) {
         *
         * @return The created GatewayServer
         */
-       static GatewayServer startGatewayServer() {
-               InetAddress localhost = InetAddress.getLoopbackAddress();
-               GatewayServer gatewayServer = new 
GatewayServer.GatewayServerBuilder()
-                       .javaPort(0)
-                       .javaAddress(localhost)
-                       .build();
-               Thread thread = new Thread(gatewayServer::start);
+       static GatewayServer startGatewayServer() throws InterruptedException, 
ExecutionException {
+               CompletableFuture<GatewayServer> gatewayServerFuture = new 
CompletableFuture<>();
+               Thread thread = new Thread(() -> {
+                       try {
+                               int freePort = NetUtils.getAvailablePort();
+                               GatewayServer server = new 
GatewayServer.GatewayServerBuilder()
+                                       .gateway(new Gateway(new 
ConcurrentHashMap<String, Object>(), new CallbackClient(freePort)))

Review comment:
       @dianfu Thanks for your reply! It seem that every time we new a 
GatewayServer, a CallbackClient would also be created, no matter whether we 
need to use the callback client. So, we may still need to set the 
executorService to be daemon.




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

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Reply via email to