Killing a thread

Daley, Mark W mark.w.daley at intel.com
Thu Aug 3 11:14:18 EDT 2000


I was just reading about this.  Here is the example:

A Thread object t supports the following methods:

<snip>

t.join([timeout])

	Waits until the thread terminates or a timeout occurs.  [timeout] is
a floating-point number specifying a timeout in seconds.  A thread can't
join itself and it's an error to join a thread before it has been started.

<snip>


This comes from Python Essential Reference (which, BTW, bears a remarkable
resemblance to the documentation supplied with the Python distribution!)

- Mark
----------------------------------------------
The opinions expressed are mine, and are not necessarily those of my
employer.


-----Original Message-----
From: pauljolly at my-deja.com [mailto:pauljolly at my-deja.com]
Sent: Thursday, August 03, 2000 7:33 AM
To: python-list at python.org
Subject: Killing a thread


Dear All,

I have a slight problem and I cannot seem to find the answer. I have
decided that using threads would be a good idea for my program written
in Python. I want to start a thread that retrieves a URL. Now, after a
certain time, say 30 seconds or one minute, I want to test whether that
thread is still running. If the thread is still running I want to kill
that thread. I am using threading module, and currently Thread() class
to create a new class object. I then start the thread using start()...
but I do not know where to go from here for the testing and the killing
part described above. Could someone please help?

I will in the end start about seven threads simultaneously and check to
see whether any of them are running after a specified time. If there
are threads running, kill them.

Best regards,


Paul


Sent via Deja.com http://www.deja.com/
Before you buy.





More information about the Python-list mailing list