[Tutor] another question ( unrelated )

shawn bright nephish at gmail.com
Fri Jul 20 18:32:12 CEST 2007


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 <kent37 at tds.net> 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
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/tutor/attachments/20070720/1b81f42c/attachment.html 


More information about the Tutor mailing list