ok, how would i have it re-initialize itself ?

yes, i want to do this on a failure condition.
something wrapped in a try - except

its long and complicated dealing with talking to a dataserver over ip and
passing byte streams back and forth.

i just need to do this for testing to see where something is failing and how
soon
i could re-connect to the data server.

whew !

thanks
shawn

On 7/20/07, Kent Johnson <[EMAIL PROTECTED]> wrote:

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