473,383 Members | 1,929 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,383 software developers and data experts.

how to drop all thread ??

if class A(
use threading,thread module
) to produce 100 thread,how to drop its (100 thread) when its running
Jul 18 '05 #1
5 1235
Leon wrote:
if class A(
use threading,thread module
) to produce 100 thread,how to drop its (100 thread) when its running


By exiting. There is no other way to stop a thread by force. Of course you
can write a run()-method like this:
def run(self):
while self.running_condition:
# do something
pass

If that running-condition is queried often enough, you can stop the thread
by setting it to false.

--
Regards,

Diez B. Roggisch
Jul 18 '05 #2
Diez B. Roggisch wrote:
Leon wrote:

if class A(
use threading,thread module
) to produce 100 thread,how to drop its (100 thread) when its running

By exiting. There is no other way to stop a thread by force.


Note that even trying to exit won't work, if the threads are not
marked as "daemon" threads... Only by calling .setDaemon(True) on
the threads before they are started will you be able to terminate
them all just by exiting.

-Peter
Jul 18 '05 #3
This reply is off topic but I couldn't resist:

The best way to get rid of thread is to adopt a kitten.

In fact, one of my cats is named Snobol because she is such a good string
manipulator.
Jul 18 '05 #4
Hi !

The best method, it is the suicide (of the threads).


Jul 18 '05 #5
Leon wrote:
if class A(
use threading,thread module
) to produce 100 thread,how to drop its (100 thread) when its running


As Roggisch suggests, the cleanest way is if the thread kills itself
once signaled by an exit condition. However, there is a non-orthodox way
of pseudo-forcibly killing threads by catching the kill signal in a
traceback. This method is summed up in Connelly Barnes's informal
KThread module:
http://www.google.com/groups?q=KThre...hon.org&rnum=1

Note it won't work in all cases, as it can't kill a thread that's made a
blocking system call. However, it may come in useful.
Jul 18 '05 #6

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

Similar topics

0
by: Lauren Quantrell | last post by:
I'm trying to drop a file from Windows Explorer (or desktop, etc.) onto a field in Access2K and capture the full file path. I found an posting below that says this is possible but I cannot...
2
by: ramesh | last post by:
hi, I am using Com+ in my application. It will have InsertRecords,selectRecords,updateRecords function. In the Web Form i have Drop-down list. I want to select records from SQL and add it to this...
6
by: Wei Junping | last post by:
Hi, all. I want my program act as an drag source and do drag and drop asynchronously. So, I created a class CDataObject which implements interfaces IDataObject and IAsyncOperation. To begin drag...
6
by: jojobar | last post by:
Hello, I look at the asp.net 2.0 web parts tutorial on the asp.net web site. I tried to run it under firefox browser but it did not run. If I want to use this feature in a commercial product...
0
by: Yavuz Bogazci | last post by:
Hi, i have build a form with a listbox and the function that he user can drag and drop files from the windows explorer in this listbox. this works for me when i start it on my localmachine. ...
14
by: axlq | last post by:
I am trying to figure out what is the minimal simplest CSS I can have to accomplish a row of tabs, with one or more tabs having a drop-down menu when you hover over it -- AND the whole tab+menu...
0
by: RHSFSS | last post by:
Hi, I have a Drag and Drop registration problem (See http://www.thescripts.com/forum/thread434707.html for similar problem post), can anyone out thereadvise on the best solution? I have a .NET 2.0 ...
2
by: Andreas Mueller | last post by:
Hi All, I'm trying to show a context menu during a drag drop operation similar to the windows explorers right click drag and drop behavior (A full working sample is at the end of the post): ...
30
ADezii
by: ADezii | last post by:
This week’s Tip of the Week will clearly demonstrate how you can dynamically set the Drop Down List Width of a Combo Box to the length of the longest item in its Row Source. The inspiration for this...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?

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.