logiplexsoftware at earthlink.net
Wed Sep 12 22:59:32 CEST 2001
On Wednesday 12 September 2001 12:23, ka wrote:
> Can someone help me with Multi-threading
> I import threading
> I start a new thread with _start_new_thread()
No. start_new_thread is for use with the "thread" module. The threading
module is a higher-level interface to that module. Basically you do this:
thread = threading.Thread(None, YourFunction)
> ????How do I know when my thread is done ??????
There are several methods, I usually use threading.Lock, threading.Condition,
threading.Event (see the docs) so that other parts of the program can check
if a thread is active.
> ????What happens if one thread crashes (happens most of the time), Can I
> catch it????
Again, you can use a lock, condition or event to notify your program that
something has happened. Simply place the threaded code inside a try..except
and set the condition/event/lock in case of an exception.
If your thread is crashing all the time, I would try and find out why and fix
it rather than simply working around it.
Logiplex Corporation (www.logiplex.net)
(503) 978-6726 x308
(800) 735-0555 x308
More information about the Python-list