You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by po...@apache.org on 2023/06/24 16:52:03 UTC

[airflow] branch main updated: Avoid permission error when asset compilation exists before killing it (#32116)

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

potiuk pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/airflow.git


The following commit(s) were added to refs/heads/main by this push:
     new 3aff742d39 Avoid permission error when asset compilation exists before killing it (#32116)
3aff742d39 is described below

commit 3aff742d3941ddcca60197e0327c46bd39471391
Author: Jarek Potiuk <ja...@potiuk.com>
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.
---
 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 1456a03acc..133e512347 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):