Inconsistent running of subprocess
in OpenSesame
Hi all,
I have noticed that in a program I am running (that was written pre 3.1), it is inconsistently calling a subroutine. Basically, if one object is picked, it should release 3 pieces of food from a dispenser (this is the .vbs file). However, it only did that on 4 of 10 trials. On the remaining 6 trials, it only release twice.
I know there have been some changes in the latest update. So, I tried changing all the time functions to clock functions, but with the same result. Can anyone help?
Thanks
if x > (self.get('xHigh') - maxClickErr) and x < (self.get('xHigh') + maxClickErr) and y > (self.get('yHigh') - maxClickErr) and y < (self.get('yHigh') + maxClickErr):
my_canvas.circle(self.get('xLow'), self.get('yLow'), 120, fill=True, color='black')
my_canvas.show()
exp.sound = pygame.mixer.Sound(high_path)
exp.sound.play()
time.sleep(.70)
subprocess.call("wscript.exe c:\invis.vbs")
time.sleep(.70)
subprocess.call("wscript.exe c:\invis.vbs")
time.sleep(.70)
subprocess.call("wscript.exe c:\invis.vbs")
time.sleep(.70)
high +=1
break

Comments
Hi,
Subprocesses are always tricky. Here's what I would do:
["wscript.exe", "c:\invis.vbs"]instead of as a singlestr. I'm surprised that it even works like this at all.subprocess.check_call()instead ofsubprocess.call()to check whether the processes ended correctly.check_call()will raise aCalledProcessErrorwhen it doesn't, whereascall()will fail silently.See also:
Cheers!
Sebastiaan
Check out SigmundAI.eu for our OpenSesame AI assistant!
Thanks! That works perfectly.