uranusjr commented on code in PR #23872:
URL: https://github.com/apache/airflow/pull/23872#discussion_r881266785
##########
airflow/utils/process_utils.py:
##########
@@ -311,3 +311,22 @@ def check_if_pidfile_process_is_running(pid_file: str,
process_name: str):
except psutil.NoSuchProcess:
# If process is dead remove the pidfile
pid_lock_file.break_lock()
+
+
+def set_new_process_group() -> bool:
+ """
+ Tries to set current process to a new process group
+ That makes it easy to kill all sub-process of this at the OS-level, rather
than having
+ to iterate the child processes.
+
+ If current process spawn by system call ``exec()`` than keep current
process group
+
+ Returns True if new process group created otherwise False
+ """
+
+ if os.getpid() == os.getsid(0):
+ # If PID = SID than process a session leader, and it is not possible
to change process group
+ return False
Review Comment:
When would this return value be useful? It is currently only used in tests,
but checking `os.setpgid`’s call count does the same thing.
--
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]