So, according to this and this, to run two python scripts simultaneously I should run them from a batch file, separated by a &
.
However, this does not seem to be working in a simple example.
I am currently trying this:
test1.py
import time
for i in range(5):
time.sleep(1)
print("Printing, test1:"+str(i))
test2.py
import time
for i in range(5):
time.sleep(2)
print("Printing, test2:"+str(i))
batch file
call "C:\Users\Username\Anaconda3\Scripts\activate.bat"
"C:\Users\Username\Anaconda3\python.exe" "C:\Users\Python\Documents\Python\Test\test1.py" &
"C:\Users\Username\Anaconda3\python.exe" "C:\Users\Python\Documents\Python\Test\test2.py" &
I would expect to see the results mingled, however, this is the outcome:
It is clear that script 2 is running after script 1.
Any ideas?
Thanks!