You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Consider this example slightly modified from your documentation:
import os
import signal
import psutil
def kill_proc_tree(sig=signal.SIGTERM, include_parent=False,
timeout=None, on_terminate=None):
"""Kill a process tree (including grandchildren) with signal
"sig" and return a (gone, still_alive) tuple.
"on_terminate", if specified, is a callabck function which is
called as soon as a child terminates.
"""
parent = psutil.Process(os.getpid())
children = parent.children(recursive=True)
if include_parent:
children.append(parent)
for p in children:
p.send_signal(sig)
gone, alive = psutil.wait_procs(children, timeout=timeout,
callback=on_terminate)
return (gone, alive)
os.getpid() is the Flask microservice
The service parent process opens childs using another python script in detached mode with p = subprocess.Popen(PYTHON_SCRIPT, env=CmdUtils.__env.get_env_and_virtual_env())
The PYTHON_SCRIPT is running system commands with variable run times (from milliseconds to minutes/hour...).
The problem is that the above piece of code will raise an error for the processes that were closed very fast.
Please revisit the examples and documentation.
The text was updated successfully, but these errors were encountered:
Consider this example slightly modified from your documentation:
The problem is that the above piece of code will raise an error for the processes that were closed very fast.
Please revisit the examples and documentation.
The text was updated successfully, but these errors were encountered: