threads only called once?

Gerson Kurz gerson.kurz at t-online.de
Wed Aug 7 09:18:33 EDT 2002


On Wed, 07 Aug 2002 08:27:14 -0400, Peter Hansen <peter at engcorp.com>
wrote:

>Why do something like that?  You can just repeatedly create
>instances of the "test" class (might be better renamed Test,
>by the way, according to the usual convention) and .start()
>them...  anyway, what's wrong with having to create a new
>thread object each time?

The thread object has some data that is meant to be persistent across
thread invokations. 

Right now, this is what (part of) my app looks like. I have a
multithreaded webserver. I have some device handler threads in the
background, that communicate with the various attached (physical)
machines. (These devices talk in the background, unrelated to any web
pages you view, using V24 communications). 

Then, you have an operation for (V24-)downloading some data to the
device. This data changes from time to time, so a new download has to
take place. 

The dl-operation takes time. The download data is not associated with
a particular thread, but with the "download" operation. So, I start a
download thread as a member function of the download class, let it
perform the download with the device, and paste messages to a
device-specific message queue. The webpage generated uses javascript
to refresh itself every second, poll those device-specific messages
and display them. 

Besides, what is wrong with reusing the same thread object each time?
;) (There seems to be no technical reason I can think off).



More information about the Python-list mailing list