0

I'm trying to launch an exe in Python to capture data from an eyetracker, I'm using Popen and it's able to launch fine. However I'm simultaneously running a psychovisual experiment using psychopy. I'm not sure how to use Popen to synchronise the launch of both processes, I know that this has something to do with threading - and a found a useful blog on the subject here (http://zulko.github.io/blog/2013/09/19/a-basic-example-of-threads-synchronization-in-python/) however, I'm not sure how to translate this to my case as I'm new to Python. Additionally, closing the exe after my experiment is over is something that I'm not sure how to actually do

my code is roughly as follows

tracker = Popen("..\API\samples\Debug\precision_accuracy.exe".split(),stdout = PIPE) # calling exe 

for i in range(stuff):
     do my experiment

I'm using windows, any help at all would be massively appreciated

skailasa
  • 121
  • 8
  • Threading is non-trivial to get right. There is a good answer here: http://stackoverflow.com/questions/375427/non-blocking-read-on-a-subprocess-pipe-in-python/4896288#4896288 – Stephen Rauch Feb 18 '17 at 22:06
  • Possible duplicate of [Non-blocking read on a subprocess.PIPE in python](http://stackoverflow.com/questions/375427/non-blocking-read-on-a-subprocess-pipe-in-python) – Stephen Rauch Feb 18 '17 at 22:06
  • A better approach would almost certainly be to communicate with the eye tracker via its API from within your PsychoPy experiment. i.e. at specific points in your script, calibrate the system, start recording, send trigger events, stop recording, etc. In fact, PsychoPy comes with the ioHub component, that handles much of this stuff for you, for some of the common eye trackers. – Michael MacAskill Feb 19 '17 at 22:27
  • Hi, thanks for replying, I have tried to do this - but the tracker I'm using hasn't got Psychopy support yet which is why I've had to resort to more desperate methods. – skailasa Feb 20 '17 at 10:09

0 Answers0