max_child_processes = 100
child_processes = []
for i, row in df.iterrows():
while len(child_processes ) >= max_child_processes:
sleep(0.1)
child_processes = [p for p in child_processes if p.poll() is None]
path = row.path
subp = subprocess.Popen(f"echo {password} | sudo -S ./recog_wav.sh {path}",
stdin=subprocess.PIPE, stdout=subprocess.PIPE, shell=True)
child_processes.appen(subp)