Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!rt.uk.eu.org!newsfeed.xs4all.nl!newsfeed3.news.xs4all.nl!xs4all!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.061 X-Spam-Evidence: '*H*': 0.88; '*S*': 0.00; 'subject:How': 0.10; 'blocks': 0.16; 'from:addr:cs': 0.16; 'from:addr:zip.com.au': 0.16; 'from:name:cameron simpson': 0.16; 'message- id:@cskk.homeip.net': 0.16; 'simpson': 0.16; 'subject:threads': 0.16; 'threads,': 0.16; 'wrote:': 0.18; 'manual': 0.22; 'header :User-Agent:1': 0.23; 'driver': 0.24; 'cheers,': 0.24; 'this:': 0.26; 'pass': 0.26; 'header:In-Reply-To:1': 0.27; "d'aprano": 0.31; 'steven': 0.31; 'device': 0.34; 'created': 0.35; 'charset :us-ascii': 0.36; 'subject:?': 0.36; 'skip:[ 10': 0.38; 'to:addr :python-list': 0.38; 'to:addr:python.org': 0.39; 'how': 0.40; 'content-disposition:inline': 0.62; 'received:121': 0.68; 'received:61': 0.74; 'done:': 0.84; 'ncr': 0.84; 'subject:being': 0.84; 'subject:check': 0.84 X-Authority-Analysis: v=2.0 cv=IccFqBWa c=1 sm=1 a=vybC443edK8SvCmZ09ZPTw==:17 a=wom5GMh1gUkA:10 a=ocHKTuOYpwYA:10 a=kj9zAlcOel0A:10 a=vrnE16BAAAAA:8 a=ZtCCktOnAAAA:8 a=ykJ_WEBzZ4MA:10 a=kZ7UWmmPAAAA:8 a=cCc2-fivUlAK0qARKtMA:9 a=CjuIK1q_8ugA:10 a=pyH5b1fOeEsA:10 a=vybC443edK8SvCmZ09ZPTw==:117 Date: Sat, 6 Jul 2013 10:45:13 +1000 From: Cameron Simpson To: python-list@python.org Subject: Re: How to check for threads being finished? MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <51d6fb8a$0$29999$c3e8da3$5496439d@news.astraweb.com> User-Agent: Mutt/1.5.21 (2010-09-15) References: <51d6fb8a$0$29999$c3e8da3$5496439d@news.astraweb.com> 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: 26 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1373071518 news.xs4all.nl 15911 [2001:888:2000:d::a6]:33217 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:50031 On 05Jul2013 16:59, Steven D'Aprano wrote: | I have a pool of worker threads, created like this: | | threads = [MyThread(*args) for i in range(numthreads)] | for t in threads: | t.start() | | I then block until the threads are all done: | | while any(t.isAlive() for t in threads): | pass This spins. How about: for t in threads: t.join() Blocks instead of polls. Cheers, -- Cameron Simpson Processes are like potatoes. - NCR device driver manual