Regarding Thread pooling

Aahz aahz at pythoncraft.com
Tue Jul 15 16:49:08 CEST 2003


In article <mailman.1058267003.16337.python-list at python.org>,
sujata <sujatay at cybage.com> wrote:
>
>        I have a query regarding threads.
>Is it possible to create thread pools in python.i.e. create threads and =
>then retrieve the memory allocated to it so that the same threads can be =
>used over and over again rather than creating new threads each time i =
>wish to execute functions many times. If its possible plz do let me know =
>how to do so.
>Can one have control over memory this way?

Certainly.  What you need to do is set up a while loop in each thread
that picks up work from a Queue.  One of the work types contains a flag
that tells the loop to exit.  (There are other ways, but that's the
simplest and most straightforward.)
-- 
Aahz (aahz at pythoncraft.com)           <*>         http://www.pythoncraft.com/

"Not everything in life has a clue in front of it...."  --JMS




More information about the Python-list mailing list