Path: csiph.com!usenet.pasdenom.info!news.albasani.net!rt.uk.eu.org!newsfeed.xs4all.nl!newsfeed3a.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.097 X-Spam-Evidence: '*H*': 0.81; '*S*': 0.00; 'solution,': 0.09; 'cc:addr :python-list': 0.11; 'thread': 0.14; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'subject:audio': 0.16; 'subject:threads': 0.16; 'wrote:': 0.18; 'obviously': 0.18; 'things.': 0.19; 'seems': 0.21; 'otherwise,': 0.22; 'cc:addr:python.org': 0.22; 'mon,': 0.24; 'cc:2**0': 0.24; 'asking': 0.27; 'header:In-Reply-To:1': 0.27; 'quickly': 0.29; 'wonder': 0.29; 'message-id:@mail.gmail.com': 0.30; "i'm": 0.30; 'that.': 0.31; 'question:': 0.31; 'quite': 0.32; "i'd": 0.34; "can't": 0.35; 'but': 0.35; 'received:google.com': 0.35; 'there': 0.35; 'really': 0.36; 'subject:?': 0.36; 'two': 0.37; 'pm,': 0.38; '12,': 0.39; 'solve': 0.60; 'simply': 0.61; "you're": 0.61; 'first': 0.61; 'back': 0.62; 'more': 0.64; 'miss': 0.74; 'obvious': 0.74; 'subject:Using': 0.84; 'upstream': 0.84; 'absolutely': 0.87; 'to:none': 0.92 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:cc :content-type; bh=kJ+KomSo0qWJBRR6Lcro5/T7D+WjKIyXuPhMjbkofwA=; b=CwU+GLfJUSGQfMx0q8HtzJryP57i2xdwDaNlXHUpZndrCB2s15P7aZSnbcQXSBnVvp rka82ovnEInWhwFb3BpSu91AM+MCZ5xYIN3y6VBF58IML+dY2H/YWJ22HYlj7jldlv1b bh+tLqsaXRKN+dZ5pSAgwdlyerA4YIXpEzmpKTbzXRDg5KiZJCPDuBDBNAxNh4zSzRRs DxocErJcjUJmbZjBmKza6tKiPZVpdKjLm9pFVuRXdeu1qYWMzlV269phvfLiEwsoSFLv Y6QONBuRewSIZNjpldTdzkObvg4iEFZ2fgZzNNa756K3NGwgxWPBql69OGKrtsNfA8XD ASqg== MIME-Version: 1.0 X-Received: by 10.52.74.196 with SMTP id w4mr15602290vdv.19.1399874309435; Sun, 11 May 2014 22:58:29 -0700 (PDT) In-Reply-To: <53706210$0$2921$426a74cc@news.free.fr> References: <536f869c$0$2178$426a74cc@news.free.fr> <536f99eb$0$2109$426a74cc@news.free.fr> <53705d34$0$2374$426a74cc@news.free.fr> <53706210$0$2921$426a74cc@news.free.fr> Date: Mon, 12 May 2014 15:58:29 +1000 Subject: Re: Using threads for audio computing? From: Chris Angelico Cc: "python-list@python.org" Content-Type: text/plain; charset=UTF-8 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 17 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1399874311 news.xs4all.nl 2970 [2001:888:2000:d::a6]:57560 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:71373 On Mon, May 12, 2014 at 3:54 PM, lgabiot wrote: > So back to my original question: A Queue and two threads (producer/consumer) > seems a good answer to my problem, or is there a better way to solve it? > (again, I'm really a beginner, so I made up this solution, but really wonder > if I do not miss a well known obvious much better idea). Well, the first thing I'd try is simply asking for more data when you're ready for it - can you get five seconds' of data all at once? Obviously this won't work if your upstream buffers only a small amount, in which case your thread is there to do that buffering; also, if you can't absolutely *guarantee* that you can process the data quickly enough, every time, then you need to use the queue to buffer that. But otherwise, it sounds like a quite reasonable way to do things. ChrisA