shawn bright wrote:
> If i have a thread, of type threading.Thread
> that i initiate with an __init__
> in the
> def run(self):
>      while 1:
>           do some stuff
> 
> 
> is there a way i can stop this thread and restart this thread from 
> within itself ?

No. A thread stops by exiting the run method, then it is done. And how 
would a stopped thread restart itself?

What you can do, is write your run() method to do whatever you want; in 
particular it could sense some condition and re-initialize itself.

If you are using a Thread subclass and overriding run() (as opposed to 
passing the run method to the constructor) you can use the subclass to 
hold any state you need and you can write/call any other methods you need.

Kent
_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

Reply via email to