I know there is the possibility to check if a subprocess is still running with .poll(). So for example:
p = subprocess.Popen(...
"""
A None value indicates that the process hasn't terminated yet.
"""
poll = p.poll()
if poll is None:
# p.subprocess is alive
In my case, I'm running multiple of the same subprocesses at the same time and I store them inside of a list called proc. Each time when I need a new subprocess I just call:
proc.append(subprocess.Popen([sys.executable,...
.poll() won't take list values so does anyone has a working example for me on how I can check if any subprocess at all is still running with the subprocesses stored inside of a list?
This is my update so far:
proc.append(subprocess.Popen([sys.executable,....
def evaluate():
global proc
global p
p = []
for t in proc:
print(t.poll())
if t.poll() is None:
p.append(0)
else:
p.append(1)
evaluate()
if 1 in p:
#some tasks running
else:
#no task running