Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #71371
| References | <536f869c$0$2178$426a74cc@news.free.fr> <roy-73C8F2.10404911052014@news.panix.com> <536f99eb$0$2109$426a74cc@news.free.fr> <53705d34$0$2374$426a74cc@news.free.fr> |
|---|---|
| Date | 2014-05-12 15:41 +1000 |
| Subject | Re: Using threads for audio computing? |
| From | Chris Angelico <rosuav@gmail.com> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.9908.1399873286.18130.python-list@python.org> (permalink) |
On Mon, May 12, 2014 at 3:33 PM, lgabiot <lgabiot@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
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Using threads for audio computing? lgabiot <lgabiot@hotmail.com> - 2014-05-11 16:18 +0200
Re: Using threads for audio computing? Roy Smith <roy@panix.com> - 2014-05-11 10:40 -0400
Re: Using threads for audio computing? lgabiot <lgabiot@hotmail.com> - 2014-05-11 17:40 +0200
Re: Using threads for audio computing? lgabiot <lgabiot@hotmail.com> - 2014-05-12 07:33 +0200
Re: Using threads for audio computing? Chris Angelico <rosuav@gmail.com> - 2014-05-12 15:41 +1000
Re: Using threads for audio computing? lgabiot <lgabiot@hotmail.com> - 2014-05-12 07:54 +0200
Re: Using threads for audio computing? Chris Angelico <rosuav@gmail.com> - 2014-05-12 15:58 +1000
Re: Using threads for audio computing? lgabiot <lgabiot@hotmail.com> - 2014-05-12 08:02 +0200
Re: Using threads for audio computing? Stefan Behnel <stefan_ml@behnel.de> - 2014-05-12 08:13 +0200
Re: Using threads for audio computing? lgabiot <lgabiot@hotmail.com> - 2014-05-12 10:14 +0200
Re: Using threads for audio computing? lgabiot <lgabiot@hotmail.com> - 2014-05-12 11:17 +0200
Re: Using threads for audio computing? Sturla Molden <sturla.molden@gmail.com> - 2014-05-14 16:23 +0200
csiph-web