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
Hi, first off thanks for making this library; it's very useful. Recently I've been running into an issue on Linux where calls to Process.children(recursive=True) take up more CPU than expected.
As you can see from the cProfile output, the call takes roughly 8 seconds of CPU time. This is strange because there are only a few subprocesses (five or less). The program is using asyncio, so there are quite a few active asyncio tasks; but these should all exist within the same thread.
It appears the real culprit here is _pslinux.py / ppid_map():
defkill_children(parent_pid=None, sig=signal.SIGTERM):
""" Forgive me father for I have sinned """try:
parent=psutil.Process(parent_pid)
exceptpsutil.NoSuchProcess:
log.debug(f"No such PID: {parent_pid}")
log.debug(f"Killing children of process ID {parent.pid}")
children=parent.children(recursive=True) # <---------forchildinchildren:
log.debug(f"Killing child with PID {child.pid}")
ifchild.name!="python":
try:
child.send_signal(sig)
exceptpsutil.NoSuchProcess:
log.debug(f"No such PID: {child.pid}")
exceptpsutil.AccessDenied:
log.debug(f"Error killing PID: {child.pid} - access denied")
The text was updated successfully, but these errors were encountered:
Summary
Description
Hi, first off thanks for making this library; it's very useful. Recently I've been running into an issue on Linux where calls to
Process.children(recursive=True)
take up more CPU than expected.As you can see from the cProfile output, the call takes roughly 8 seconds of CPU time. This is strange because there are only a few subprocesses (five or less). The program is using asyncio, so there are quite a few active asyncio tasks; but these should all exist within the same thread.
It appears the real culprit here is
_pslinux.py
/ppid_map()
:Here is the python code that calls it:
The text was updated successfully, but these errors were encountered: