I use python to experiment with video games in cognitive science. I am testing a device that detects eye movements through EOG , and this device is talking to a computer via USB. In order to guarantee constant reading of data from USB, while the experiment performs other actions (for example, changing the display, etc.), I thought that I would use a multiprocessor module (of course, with a multi-core computer), placing the USB reading work separately workflow and use the queue to inform the employee when interesting events occur in the experiment. Nevertheless, I came across some strange behavior that even when there is 1 second between the infection of an employee with 2 different messages, when I look at the working output at the end, he seems to have received the second almost immediately after the first. Of course, I encoded something terrible, but I don’t see that, so I am very grateful for the help that anyone can provide.
I tried breaking my code into a minimal example demonstrating this behavior. If you go to this topic:
https://gist.github.com/914070
you will find "multiprocessing_timetravel.py", which encodes the example, and ".R analysis", which analyzes the file "temp.txt" that results from running "multiprocessing_timetravel.py". "analysis.R" is written to R and requires that you have the plyr library installed, but I also included an example output from the analysis in the "analysis_results.txt" file in gist.
source share