potiuk commented on a change in pull request #19935:
URL: https://github.com/apache/airflow/pull/19935#discussion_r761382587



##########
File path: airflow/utils/process_utils.py
##########
@@ -68,36 +73,51 @@ def on_terminate(p):
 
     def signal_procs(sig):
         try:
-            os.killpg(pgid, sig)
+            logger.info("Sending the signal %s to group %s", sig, 
process_group_id)
+            os.killpg(process_group_id, sig)
         except OSError as err:
             # If operation not permitted error is thrown due to run_as_user,
             # use sudo -n(--non-interactive) to kill the process
             if err.errno == errno.EPERM:
                 subprocess.check_call(
-                    ["sudo", "-n", "kill", "-" + str(int(sig))] + [str(p.pid) 
for p in children]
+                    ["sudo", "-n", "kill", "-" + str(int(sig))]
+                    + [str(p.pid) for p in all_processes_in_the_group]
                 )
+            elif err.errno == errno.ESRCH:
+                # There is a rare condition that the process has not managed 
yet to change it's process
+                # group. In this case os.killpg fails with ESRCH error
+                # So we additionally send a kill signal to the process itself.
+                logger.info(
+                    "Sending the signal %s to process %s as process group is 
missing.", sig, process_group_id
+                )
+                os.kill(process_group_id, sig)

Review comment:
       Fixed!




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

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to