On Mon, May 12, 2014 at 3:33 PM, lgabiot <lgab...@hotmail.com> wrote: > But AFAIK the python GIL (and in smaller or older computers that have only > one core) does not permit true paralell execution of two threads. I believe > it is quite like the way multiple processes are handled by an OS on a single > CPU computer: process A has x CPU cycles, then process B has y CPU cycles, > etc... > So in my case, I must have a way to make sure that: > thread 1 (which gets audio from Pyaudio and put() it in the Queue) is not > interrupted long enough to miss a sample. > If I suppose a worst case scenario for the computer, like a raspberry-pi, > the CPU speed is 700MHz, which gives approx 14 000 CPU cycles between each > audio samples (at 48 kHz FS). I don't know if 14 000 CPU cycle is a lot or > not for the tasks at hands. > > Well, at least, it is what I understand, but since I'm really both a > beginner and an hobbyist, I might be totally wrong...
The GIL is almost completely insignificant here. One of your threads will be blocked practically the whole time (waiting for more samples; collecting them into a numpy array doesn't take long), and the other is, if I understand correctly, spending most of its time inside numpy, which releases the GIL. You should be able to thread just fine. ChrisA -- https://mail.python.org/mailman/listinfo/python-list