Re: How to check for threads being finished?

2013-07-06 Thread Stefan Behnel
Irmen de Jong, 05.07.2013 19:12: > On 5-7-2013 18:59, Steven D'Aprano wrote: >> 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

Re: How to check for threads being finished?

2013-07-05 Thread Steven D'Aprano
On Fri, 05 Jul 2013 19:12:44 +0200, Irmen de Jong wrote: > On 5-7-2013 18:59, Steven D'Aprano wrote: >> 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

Re: How to check for threads being finished?

2013-07-05 Thread Cameron Simpson
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): | pa

Re: How to check for threads being finished?

2013-07-05 Thread Ian Kelly
On Fri, Jul 5, 2013 at 10:59 AM, 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

Re: How to check for threads being finished?

2013-07-05 Thread Irmen de Jong
On 5-7-2013 18:59, Steven D'Aprano wrote: > 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

Re: How to check for threads being finished?

2013-07-05 Thread Chris Angelico
On Sat, Jul 6, 2013 at 2:59 AM, Steven D'Aprano wrote: > I then block until the threads are all done: > > while any(t.isAlive() for t in threads): > pass > Using the threading module, I assume. Is there any reason you can't simply join() each thread in succession? ChrisA -- http://mail.pyth

How to check for threads being finished?

2013-07-05 Thread Steven D'Aprano
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? S