WeiZhong94 commented on a change in pull request #11749: [FLINK-16669][python][table] Support Python UDF in SQL function DDL. URL: https://github.com/apache/flink/pull/11749#discussion_r409534525
########## File path: flink-python/src/main/java/org/apache/flink/client/python/PythonDriver.java ########## @@ -67,20 +69,22 @@ public static void main(String[] args) { Configuration config = ExecutionEnvironment.getExecutionEnvironment().getConfiguration(); // start gateway server - GatewayServer gatewayServer = startGatewayServer(); + GatewayServer gatewayServer = PythonEnvUtils.startGatewayServer(); // commands which will be exec in python progress. final List<String> commands = constructPythonCommands(pythonDriverOptions); try { // prepare the exec environment of python progress. String tmpDir = System.getProperty("java.io.tmpdir") + File.separator + "pyflink" + File.separator + UUID.randomUUID(); - PythonDriverEnvUtils.PythonEnvironment pythonEnv = PythonDriverEnvUtils.preparePythonEnvironment( - config, pythonDriverOptions.getEntryPointScript().orElse(null), tmpDir); - // set env variable PYFLINK_GATEWAY_PORT for connecting of python gateway in python progress. - pythonEnv.systemEnv.put("PYFLINK_GATEWAY_PORT", String.valueOf(gatewayServer.getListeningPort())); // start the python process. - Process pythonProcess = PythonDriverEnvUtils.startPythonProcess(pythonEnv, commands); + Process pythonProcess = PythonEnvUtils.launchPy4jPythonClient( + gatewayServer, + config, + commands, + pythonDriverOptions.getEntryPointScript().orElse(null), + tmpDir); + setGatewayServer(gatewayServer); Review comment: As the `PythonDriver`, `PythonGatewayServer`, `PythonFunctionFactory` will share the same gatewayServer object, it is necessary to set the gatewayServer to a static variable here. ---------------------------------------------------------------- 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 With regards, Apache Git Services