Note that there are some explanatory texts on larger screens.

plurals
  1. POApparent time-travelling via python's multiprocessing module: surely I've done something wrong
    text
    copied!<p>I use python for video-game-like experiments in cognitive science. I'm testing out a device that detects eye movements via <a href="http://en.wikipedia.org/wiki/EOG" rel="nofollow">EOG</a>, and this device talks to the computer via USB. To ensure that data is being continuously read from the USB while the experiment does other things (like changing the display, etc), I thought I'd use the multiprocessing module (with a multicore computer of course), put the USB reading work in a separate worker process, and use a queue to tell that worker when events of interest occur in the experiment. However, I've encountered some strange behaviour such that even when there is 1 second between the enqueuing of 2 different messages to the worker, when I look at the worker's output at the end, it seems to have received the second almost immediately after the first. Surely I've coded something awry, but I can't see what, so I'd very much appreciate help anyone can provide.</p> <p>I've attempted to strip down my code to a minimal example demonstrating this behaviour. If you go to this gist:</p> <p><a href="https://gist.github.com/914070" rel="nofollow">https://gist.github.com/914070</a></p> <p>you will find "multiprocessing_timetravel.py", which codes the example, and "analysis.R", which analyzes the "temp.txt" file that results from running "multiprocessing_timetravel.py". "analysis.R" is written in R and requires you have the plyr library installed, but I've also included example of the analysis output in the "analysis_results.txt" file at the gist.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload