473,394 Members | 1,867 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

How can I tell when the threads that I spawn are done in python


Hi,

In my python scripts, I create thread likes this:
// for example threadCount is 10
for j in range(int(threadCount)):
t = MyThread()
t.start()

// wait all the threads are done
doSomething()

My question is how can i tell when all the threads are done before I
call doSomething()?

Thank you.

Mar 24 '07 #1
1 1173
On Mar 24, 9:45 am, "ogerchi...@gmail.com" <ogerchi...@gmail.com>
wrote:
Hi,

In my python scripts, I create thread likes this:
// for example threadCount is 10
for j in range(int(threadCount)):
t = MyThread()
t.start()

// wait all the threads are done
doSomething()

My question is how can i tell when all the threads are done before I
call doSomething()?
If you are using the threading module for your threads, Thread objects
have a join method that you could call. Stash away all your Thread
objects in a list and call join() on all of them.
--
Kushal Kumaran

Mar 24 '07 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Birch | last post by:
I have a python script that uses the print function throughout, and as well uses calls to os.system() to spawn DOS commandline executables. My issue is that I redirect all of the output from this...
11
by: Przemysław Różycki | last post by:
Hello, I have written some code, which creates many threads for each connection ('main connection'). The purpose of this code is to balance the load between several connections ('pipes'). The...
23
by: Jeff Rodriguez | last post by:
Here's what I want do: Have a main daemon which starts up several threads in a Boss-Queue structure. From those threads, I want them all to sit and watch a queue. Once an entry goes into the...
3
by: cider123 | last post by:
I have a simple Window Service that loads up a list of Folders to monitor, along with parameters for a maintenance profile. Every time the interval is reached, the Window Service spawns off a...
9
by: jdlists | last post by:
I have inheirted some existing code, that i will explain in a moment, have needed to extend and ultimately should be able to run in threads. I've done a bunch of work with python but very little...
2
by: S.Mohideen | last post by:
Hi All, Can you please suggest a technique in Python where we can spawn few number of worker threads and later map them to a function/s to execute individual Jobs. Any references would be...
4
by: herman | last post by:
Hi, In my python program, I would to like to spwan 5 threads, for the them for 5 minutes maximum and the continue. Here is my script: threads = for j in range(5): t = MyThread()...
1
by: Vishal Sethia | last post by:
Just trying to understand the behaviour of spawn. Consider I have a function which creates two threads. And in one of the threads I make a call to pexpect.spawn. spawn would fork and create a new...
167
by: darren | last post by:
Hi I have to write a multi-threaded program. I decided to take an OO approach to it. I had the idea to wrap up all of the thread functions in a mix-in class called Threadable. Then when an...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.