newbee: Simple Backend Python Script Question

joe shoemaker joemystery123 at gmail.com
Fri Sep 14 10:27:45 EDT 2007


I need to create python script that is threaded. So the main program will
run in infinite loop and just retrieving messages and putting them in a
queue. (Main thread)

I need child threads from a pool to process the queue. When there is no
stuff in the queue, they go to the pool and become available but they don't
terminate. This has to be done continuously.

Main program need to keep putting stuff in the queue, when there are no
messages, then it sleeps for short time and check back to see any messages.

To do this, I guess you don't write joinAll(), so that the main threads just
don't wait for the child but goes to work.

am I right?

Also, child threads (a function that is threaded) will make connecitons to
the database. I am planning to use threadpool, so that threads reuse the
connections. So do you close the database connection at the end of the
function? If not then the connection will be opened forever?


Joe
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20070914/245d7b31/attachment.html>


More information about the Python-list mailing list