I am trying to run a web application on glitch. I have one Flask based python file that is already running (call that a.py). I want to have another application (b.py) running concurrently on the same project. Is this possible?
I have tried: ` “start”: “PYTHONUNBUFFERED=true python3 a.py && python3 b.py” in my glitch.json but it does not seem to work.
os.system('python ' + name)
// Execute a.py on a thread (concurrently)
a = threading.Thread(target=execute_script, args=('a.py',))
// Execute b.py on a thread (concurrently)
b = threading.Thread(target=execute_script, args=('b.py',))
// Block main execution until a.py is terminated
// Block main execution until b.py is terminated
Also note that you can change PYTHONUNBUFFERED=true python3 a.py && python3 b.py to run the processes in the background: PYTHONUNBUFFERED=true python3 a.py & python3 b.py &. However, @Joprocorp’s solution using threading from python itself is the best way to go, especially as you get far more control over the scripts.