I am trying to continuously run a python script with random parameters from another python script, where each run is in its own tmux session. A very simplified overview of what I'm trying to do goes like this:
# Python script to run other python scripts from subprocess import call import random while True param = randint(1,100) runmyscript ="tmux send-keys -t mysession"+str(param)+" 'python myscript.py param' " call(runmyscript) #Wait until myscript.py is done running in its tmux session <-- How to do that?
For example, let's say that the random numbers are 57, 61, 88 ... etc. The above script should run:
- 'myscript.py 57' in a tmux session called "mysession57"
- 'myscript.py 61' in a tmux session called "mysession61"
- 'myscript.py 88' in a tmux session called "mysession88" ... etc
But how can I make sure that the script waits until each script in its tmux session is finished?