Multipurpose with python : <p>I need to improve a script that runs 3 python scripts in parallel at the same time, I have this script below ready, only it is jumping some scripts on the list, I don't know why this is happening.</p>

<p>Code:</p>

<pre><code>import sys
import asyncio


scriptspy = [
    '/scipts/sp01.py',
    '/scipts/sp02.py',
    '/scipts/sp03.py', 
    '/scipts/sp04.py',
    '/scipts/sp05.py',
    '/scipts/sp06.py',
    '/scipts/sp07.py', 
    '/scipts/sp08.py',
    '/scipts/sp09.py',
    '/scipts/sp10.py',
    '/scipts/sp11.py', 
    '/scipts/sp12.py',
    '/scipts/sp13.py',
    '/scipts/sp14.py',
    '/scipts/sp15.py', 
    '/scipts/sp16.py',
    '/scipts/sp17.py',
    '/scipts/sp18.py',
    '/scipts/sp19.py', 
    '/scipts/sp20.py',
    '/scipts/sp21.py',
    '/scipts/sp22.py',
    '/scipts/sp23.py', 
    '/scipts/sp24.py',

]

#linux

async def main():
    task_run= set()
    while scriptspy:
        # start 3 scripts
        while len(task_run) &lt; 3 and scriptspy:
            script = scriptspy.pop()
            p = await asyncio.create_subprocess_exec(sys.executable, script)
            task = asyncio.create_task(p.wait())
            task_run.add(task)
        # wait one and start
        task_run, task_end = await asyncio.wait(task_run, return_when=asyncio.FIRST_COMPLETED)
    await asyncio.wait(task_run, return_when=asyncio.ALL_COMPLETED)


asyncio.run(main())
</code></pre>

<p>Detail
S.O Execute: Linux (Ubuntu)
Python: 3.7</p>
