logiplexsoftware at earthlink.net
Wed Mar 6 23:10:43 CET 2002
On Wed, 6 Mar 2002 13:26:12 -0800
Cliff Wells wrote:
> The approach I would take, based upon the information given, is to have
> thread A retrieve the data every .1s (using time.sleep), when the data
> retrieved, put it on a Queue and go back to sleep. Thread B blocks on
> Queue until data is available. When data becomes available, B processes
> that data and place it on a second Queue for thread C (thread C handling
> HTTP requests) to deal with.
Hm. Okay, I had to reconsider this. Clearly if the processing is slower
than .1s and data is being added to it every .1s, the Queue is going to
endlessly grow as more data is added to it. If this is the case, it might
make sense to have more than one consumer thread (B) doing the processing.
Also, if thread C is only interested in serving up the latest results, then
rather than a Queue between threads B and C, I think I would use a shared
object (protected by locks) for holding the last result. Thread C could
simply take a copy of this object when it gets a HTTP request.
Cliff Wells, Software Engineer
Logiplex Corporation (www.logiplex.net)
(503) 978-6726 x308 (800) 735-0555 x308
More information about the Python-list