collect data using threads

Peter Hansen peter at engcorp.com
Tue Jun 14 20:54:20 EDT 2005


Toby Dickenson wrote:
> But it might not "show up" until too late.
> 
> The consumer thread that called get_data presumably does something with that 
> list, such as iterating over its contents. It might only "show up" after that 
> iteration has finished, when the consumer has discarded its reference to the 
> shared list.

I was going to point out that the consuming thread is the one calling 
get_data(), and therefore by the time it returns (to iterate over the 
contents), self.data has already been rebound to a new list.

That was before Kent correctly analyzed this yet again and shows how the 
on_received call can itself be the source of the trouble, via the 
separate attribute lookup and append call.  (I'm going to hand in my 
multi-threading merit badge and report to Aahz for another Queue 
"reprogramming" session for missing on this twice.)

-Peter



More information about the Python-list mailing list