You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@flink.apache.org by hx...@apache.org on 2021/12/07 02:05:22 UTC

[flink] branch master updated: [FLINK-23493][python] Remove the calling of child process in the beam_boot.py

This is an automated email from the ASF dual-hosted git repository.

hxb pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/flink.git


The following commit(s) were added to refs/heads/master by this push:
     new fb38c99  [FLINK-23493][python] Remove the calling of child process in the beam_boot.py
fb38c99 is described below

commit fb38c99a38c63ba8801e765887f955522072615a
Author: huangxingbo <hx...@gmail.com>
AuthorDate: Mon Dec 6 19:57:23 2021 +0800

    [FLINK-23493][python] Remove the calling of child process in the beam_boot.py
    
    This closes #18025.
---
 flink-python/pyflink/fn_execution/beam/beam_boot.py            | 6 +++---
 flink-python/pyflink/fn_execution/beam/beam_sdk_worker_main.py | 4 +++-
 2 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/flink-python/pyflink/fn_execution/beam/beam_boot.py b/flink-python/pyflink/fn_execution/beam/beam_boot.py
index a0f2da0..0210ffb 100644
--- a/flink-python/pyflink/fn_execution/beam/beam_boot.py
+++ b/flink-python/pyflink/fn_execution/beam/beam_boot.py
@@ -29,7 +29,6 @@ harness of Apache Beam.
 """
 import argparse
 import os
-from subprocess import call
 
 import grpc
 import logging
@@ -114,5 +113,6 @@ if __name__ == "__main__":
             logging.info("Shut down Python harness due to FLINK_BOOT_TESTING is set.")
             exit(0)
 
-        call([python_exec, "-m", "pyflink.fn_execution.beam.beam_sdk_worker_main"],
-             stdout=sys.stdout, stderr=sys.stderr, env=env)
+        from pyflink.fn_execution.beam import beam_sdk_worker_main
+
+        beam_sdk_worker_main.main()
diff --git a/flink-python/pyflink/fn_execution/beam/beam_sdk_worker_main.py b/flink-python/pyflink/fn_execution/beam/beam_sdk_worker_main.py
index 77e20d3..b98f28b 100644
--- a/flink-python/pyflink/fn_execution/beam/beam_sdk_worker_main.py
+++ b/flink-python/pyflink/fn_execution/beam/beam_sdk_worker_main.py
@@ -54,7 +54,7 @@ class CustomPrint(object):
             self._msg_buffer.clear()
 
 
-if __name__ == '__main__':
+def main():
     import builtins
     import logging
     from functools import partial
@@ -67,5 +67,7 @@ if __name__ == '__main__':
 
     custom_print = CustomPrint(print)
     builtins.print = custom_print.print
+    # Remove all the built-in log handles
+    logging.getLogger().handlers = []
     apache_beam.runners.worker.sdk_worker_main.main(sys.argv)
     custom_print.close()