This is an automated email from the ASF dual-hosted git repository. potiuk pushed a commit to branch v2-6-test in repository https://gitbox.apache.org/repos/asf/airflow.git
commit d042f010d3702b69856493a9ff8f6d7a1924bf1f Author: Jarek Potiuk <[email protected]> AuthorDate: Sat Jun 24 18:51:57 2023 +0200 Avoid permission error when asset compilation exists before killing it (#32116) After #32114 the atexit registered killpg produces Permission Error in stdout when the group was missing (basically when the asset compilation stopped). Changing it to ignore the error avoids the false negative appear in the output. (cherry picked from commit 3aff742d3941ddcca60197e0327c46bd39471391) --- dev/breeze/src/airflow_breeze/utils/run_utils.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/dev/breeze/src/airflow_breeze/utils/run_utils.py b/dev/breeze/src/airflow_breeze/utils/run_utils.py index cee1a555bc..bf089fac03 100644 --- a/dev/breeze/src/airflow_breeze/utils/run_utils.py +++ b/dev/breeze/src/airflow_breeze/utils/run_utils.py @@ -444,6 +444,18 @@ def _run_compile_internally(command_to_execute: list[str], dev: bool) -> RunComm sys.exit(1) +def kill_process_group(gid: int): + """ + Kills all processes in the process group and ignore if the group is missing. + + :param gid: process group id + """ + try: + os.killpg(gid, signal.SIGTERM) + except OSError: + pass + + def run_compile_www_assets( dev: bool, run_in_background: bool, @@ -474,7 +486,7 @@ def run_compile_www_assets( pid = os.fork() if pid: # Parent process - send signal to process group of the child process - atexit.register(os.killpg, pid, signal.SIGTERM) + atexit.register(kill_process_group, pid) else: # Check if we are not a group leader already (We should not be) if os.getpid() != os.getsid(0):
