I have the following while loop in my Python script
while 1:
functionToGetXandY
if x == z:
os.system("google-chrome --start-maximized " + x)
currentLink = latestLink
if y == z:
subprocess.call([vlc_path, "--fullscreen", z])
time.sleep(1)
Whenever Chrome or VLC is started through the script the loop seems to stop – or sometimes wait until the opened window is closed. What am I missing?
Note: The infinite loop is on purpose – the script continuously checks an XML file to execute a command (that part works)
Both
subprocess.callandos.systemare blocking calls. This means that when you call either of them, your script pauses until the program you called exits.If you want your Python script to continue executing immediately, you may want to look into
subprocess.Popenwhich is non-blocking and takes pretty much the same argumentssubprocess.calltakes