File tree Expand file tree Collapse file tree 1 file changed +7
-5
lines changed Expand file tree Collapse file tree 1 file changed +7
-5
lines changed Original file line number Diff line number Diff line change @@ -1225,14 +1225,16 @@ def _get_num_threads(proc):
1225
1225
1226
1226
# Init variables
1227
1227
num_threads = proc .num_threads ()
1228
-
1228
+ alive_procs = 0
1229
1229
# Iterate through child processes and get number of their threads
1230
1230
try :
1231
- num_children = len (proc .children ())
1231
+ # num_children = len(proc.children())
1232
1232
for child in proc .children (recursive = True ):
1233
- #num_threads += child.num_threads()
1234
- num_threads = max (num_threads , num_children ,
1235
- child .num_threads (), len (child .children ()))
1233
+ if child .status () == psutil .STATUS_RUNNING :
1234
+ alive_procs += 1
1235
+ num_threads += max (alive_procs , child .num_threads ()) #child.num_threads()
1236
+ #num_threads = max(num_threads, num_children,
1237
+ # child.num_threads(), len(child.children()))
1236
1238
except psutil .NoSuchProcess :
1237
1239
pass
1238
1240
You can’t perform that action at this time.
0 commit comments