Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #50006
| Path | csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!us.feeder.erje.net!newsfeed.fsmpi.rwth-aachen.de!newsfeed.kamp.net!newsfeed.kamp.net!newsfeed.freenet.ag!news2.euro.net!newsfeed.xs4all.nl!newsfeed4.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <ian.g.kelly@gmail.com> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.118 |
| X-Spam-Level | * |
| X-Spam-Evidence | '*H*': 0.77; '*S*': 0.01; 'subject:How': 0.10; 'thread': 0.14; '10:59': 0.16; 'subject:threads': 0.16; 'threads,': 0.16; 'wrote:': 0.18; 'stick': 0.24; 'this:': 0.26; 'pass': 0.26; 'header:In-Reply-To:1': 0.27; 'appreciated.': 0.29; 'am,': 0.29; 'message-id:@mail.gmail.com': 0.30; "d'aprano": 0.31; 'steven': 0.31; 'probably': 0.32; 'fri,': 0.33; 'created': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'choosing': 0.36; 'subject:?': 0.36; 'should': 0.36; 'so,': 0.37; 'question,': 0.38; 'skip:[ 10': 0.38; 'to:addr:python-list': 0.38; 'to:addr:python.org': 0.39; 'how': 0.40; 'jul': 0.74; 'done:': 0.84; 'subject:being': 0.84; 'subject:check': 0.84; '2013': 0.98 |
| DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type; bh=PPJnxLOD27FvjwunAlQIGHgmpPy2C8RTKqz8wVwPWkA=; b=DeVm7ewIplA0qFsjwmyOIVkJ4V7OK8sjtW2sxdvSSshxGC4NzkRXOdjcW8Wn/bagfe GYqvx6JL4Wa9TFBm7TM8oK4I/gfKyJMVDwAPPJfHTwhxzbz5aVLWgyLfNBIveEn+IuY9 PqMqbngCLqUg5ChRqH56MS79N4ZSsRziLyiUUhUhnTq2KdKxW9IoQApNtecWpFiYg0Ky q/aqCb9qTvvfNrByj4uvvZto9bv+/ypQX+tSl+r7PiPKArPdK/1eoSQaUfKWUapYgE54 Kf1GNQfPF7+buWuG0i1n3PD41L/6k4fe9v7yJ90qck2F4a3YxLK3+TrD0ZLUi1quVSAf +lig== |
| X-Received | by 10.68.29.2 with SMTP id f2mr10650423pbh.184.1373044751658; Fri, 05 Jul 2013 10:19:11 -0700 (PDT) |
| MIME-Version | 1.0 |
| In-Reply-To | <51d6fb8a$0$29999$c3e8da3$5496439d@news.astraweb.com> |
| References | <51d6fb8a$0$29999$c3e8da3$5496439d@news.astraweb.com> |
| From | Ian Kelly <ian.g.kelly@gmail.com> |
| Date | Fri, 5 Jul 2013 11:18:31 -0600 |
| Subject | Re: How to check for threads being finished? |
| To | Python <python-list@python.org> |
| Content-Type | text/plain; charset=ISO-8859-1 |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.15 |
| Precedence | list |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe> |
| List-Archive | <http://mail.python.org/pipermail/python-list/> |
| List-Post | <mailto:python-list@python.org> |
| List-Help | <mailto:python-list-request@python.org?subject=help> |
| List-Subscribe | <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.4305.1373044760.3114.python-list@python.org> (permalink) |
| Lines | 22 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1373044760 news.xs4all.nl 15922 [2001:888:2000:d::a6]:45930 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:50006 |
Show key headers only | View raw
On Fri, Jul 5, 2013 at 10:59 AM, Steven D'Aprano
<steve+comp.lang.python@pearwood.info> 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
>
>
> Is that the right way to wait for the threads to be done? Should I stick
> a call to time.sleep() inside the while loop? If so, how long should I
> sleep? That's probably an unanswerable question, but some guidelines on
> choosing the sleep time will be appreciated.
for thread in threads:
thread.join()
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
How to check for threads being finished? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-07-05 16:59 +0000
Re: How to check for threads being finished? Chris Angelico <rosuav@gmail.com> - 2013-07-06 03:11 +1000
Re: How to check for threads being finished? Irmen de Jong <irmen.NOSPAM@xs4all.nl> - 2013-07-05 19:12 +0200
Re: How to check for threads being finished? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-07-06 02:18 +0000
Re: How to check for threads being finished? Stefan Behnel <stefan_ml@behnel.de> - 2013-07-06 10:49 +0200
Re: How to check for threads being finished? Ian Kelly <ian.g.kelly@gmail.com> - 2013-07-05 11:18 -0600
Re: How to check for threads being finished? Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2013-07-05 16:13 -0400
Re: How to check for threads being finished? Cameron Simpson <cs@zip.com.au> - 2013-07-06 10:45 +1000
csiph-web