The most common interruptions of operating systems are variable enough to destroy the time in your experiment, regardless of your programming language. Python adds its own insecurity. Windows interrupts are especially bad. On Windows, most interrupts are serviced after about 4 milliseconds, but sometimes interrupts last longer than 35 milliseconds! (Windows 7).
I would recommend trying the PsycoPy app to see if it works for you. He approaches this problem by trying to get the graphics card to work in openGL, however, some of this code still works outside the graphics card and is subject to interruptions in the operating system. Your existing python code may not be compatible with PsycoPy, but at least you will stay in Python. PsycoPy is particularly good at demonstrating visual stimulation without time problems. See this page in your documentation to see how you will handle the click of a button: http://www.psychopy.org/api/event.html
To solve your problem correctly, you need a real-time operating system such as LinuxRT or QNX. You can try the python application in one of them to make sure that running python in real time is good enough, but even python introduces variability. If python decides to garbage collect, you will have a crash. Python itself is not real-time.
National Instruments is selling a program that allows you to program in real time in the very user-friendly LabviewRT programming language. LabviewRT pushes your code to a real-time FPGA daughter board. It is expensive.
I strongly recommend that you not only minimize this problem, but solve it , otherwise your reviewers will be uncomfortable.
lee
source share