[Tutor] quick question about threads
nephish
nephish at xit.net
Wed Jan 18 03:59:13 CET 2006
all i needed to know, thanks very much
shawn
On Tue, 2006-01-17 at 21:53 -0500, Kent Johnson wrote:
> nephish wrote:
> > Hey there, i have a program written in python that uses four threads
> > that run all at the same time. Now i want to add a new thread with the
> > same basic structure (threading.thread) that will run only when needed.
> > This one will not run in a loop, it will just run once and quit.
> > So, i may need this to be running several times at once because it will
> > have a 15 second delay written into it.
> > My question is, after the script is done, will it be safe ? i mean, over
> > the course of a few days, it may run this thing a few hundred times. if
> > it is simple like this
> >
> > threading.thread
> > print 'here is something to say'
> > time.sleep(15)
> > print 'here is something else'
> >
> > do i need to include a special command to kill the thread, or will it
> > just finish and everything will be ok then ?
>
> Assuming you are showing the run() method of your thread above, it
> should be fine. If the run() method exits the thread terminates and you
> don't have to worry about it any more. Make sure you don't keep any
> references to the threads so they can be garbage-collected.
>
> Kent
>
> _______________________________________________
> Tutor maillist - Tutor at python.org
> http://mail.python.org/mailman/listinfo/tutor
More information about the Tutor
mailing list