En Fri, 13 Mar 2009 19:07:46 -0200, aiwarrior <zube...@yahoo.com.br> escribió:

I recently am meddling with threads and wanted to make a threaded
class that instead of processing anything just retrieves data from a
file and returns that data to a main thread that takes all the
gathered data and concatenates it sequentially.
An example is if we want to get various ranges of an http resource in
paralell

The usual way to communicate between threads is using a Queue object.
Instead of (create a thread, do some work, exit/destroy thread) you could create the threads in advance (a "thread pool" of "worker threads") and make them wait for some work to do from a queue (in a quasi-infinite loop). When work is done, they put results in another queue. The main thread just places work units on the first queue; another thread reassembles the pieces from the result queue. For an I/O bound application like yours, this should work smoothly.
You should be able to find examples on the web - try the Python Cookbook.

--
Gabriel Genellina

--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to