Speeding up network access: threading?

MRAB python at mrabarnett.plus.com
Tue Jan 5 12:02:29 EST 2010


Jens Müller wrote:
> Hello,
> 
>> The fairly obvious thing to do is use a queue.queue for tasks and another
>> for results and a pool of threads that read, fetch, and write.
> 
> Thanks, indeed.
> 
> Is a list thrad-safe or do I need to lock when adding the results of my
> worker threads to a list? The order of the elements in the list does not
> matter.
> 
Terry said "queue". not "list". Use the Queue class (it's thread-safe)
in the "Queue" module (assuming you're using Python 2.x; in Python 3.x
it's called the "queue" module).



More information about the Python-list mailing list